Tag: uiview

将调用removeFromSuperview两次导致崩溃或副作用

我有一个UIView元素,我添加到主视图控制器。 由于我的代码的devise,所以碰巧removeFromSuperview在我的代码的不同位置被调用两次。 [myview removeFromSuperview]; 这就是我的代码,所以我想知道如果调用“removeFromSuperview”会导致任何问题。 或者如何检查视图是否在超视图中,只有删除它。 例如 if (myview in superview) [myview removeFromSuperview]; else do nothing

处理ios设备方向

我有我的uiviews取决于设备方向的问题… 我遇到的主要问题是 UIDeviceOrientationFaceUp UIDeviceOrientationFaceDown 正在搞乱我的观点我只想支持肖像和风景(左),所以如果设备改变方向我的观点改变自己正确.. 这是我目前实施的。 基本上它是一个从屏幕底部向上滚动的UIView,在这个视图中有几个button,用户可以select加载不同的视图。 #pragma jumpBarButtons – (void)jumpBarButtonPosition { //orientation stuff if (jumpBar.isViewLoaded) { UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; switch (orientation) { case UIDeviceOrientationPortrait: { NSLog(@"Portrait"); // Row one jumpButton1.frame = CGRectMake(18.45, 23.0, 57.0, 57.0); jumpButton2.frame = CGRectMake(93.9, 23.0, 57.0, 57.0); jumpButton3.frame = CGRectMake(169.35, 23.0, 57.0, 57.0); jumpButton4.frame = CGRectMake(244.8, 23.0, […]

把以前增加的观点带到前面

我的问题是以下几点: 我有一个视图,并为该视图添加3个子视图( view1 , view2 , view3 )的顺序。 意见略有重叠。 我想把第一个观点带到最前面,但是我不能得到它的工作。 我试图用insertSubview:atIndex:添加视图,并给view1一个更大的索引,我尝试使用addSubview:然后bringSubviewToTop但似乎没有工作。 有任何想法吗? PS我不能以不同的顺序添加视图。 他们必须按此顺序添加。

UIAlertView上面的UIView

在我的应用程序中,使用locking屏幕。 有时会显示UIAlertView ,现在当用户将应用程序发送到后台并将其重新放在前面时, UIAlertview会显示在locking屏幕上方。 是否有可能添加一个UIViewController的视图高于一切,即上面的UIAlertView ?

更改文字后无法更改UISearchBar取消button的标题颜色。

我正在使用此代码来更改UISearchBar取消button标题: -(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller{ self.searchDisplayController.searchBar.showsCancelButton = YES; UIView* view=_otsinguRiba.subviews[0]; for (UIView *subView in view.subviews) { if ([subView isKindOfClass:[UIButton class]]) { UIButton *cancelButton = (UIButton*)subView; if (cancelButton) { [cancelButton setTitle:@"Test") forState:UIControlStateNormal]; [cancelButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; } } } } 虽然改变文字工作正常,改变颜色不。 它保持黑色。

用drawRect UIViewanimationbackgroundColor:

我有一个观点,能够自我反思。 这实际上是UICollectionView一个子类,但我只是在与UIView特定的东西挣扎; backgroundColor。 我只是添加了一个UIPanGestureRecognizer ,保存起始点在UIGestureRecognizerStateBegan和终点在UIGestureRecognizerStateChanged 。 然后我使用-drawRect:方法来绘制实际的path: – (void)awakeFromNib { UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)]; [self addGestureRecognizer:pan]; } – (void)panGesture:(UIPanGestureRecognizer *)panRecon { if([panRecon state] == UIGestureRecognizerBegan) { startPoint = [panRecon locationInView:self]; } else if([panRecon state] == UIGestureRecognizerChanged) { endPoint = [panRecon locationInView:self]; [self setNeedsDisplay]; } else if([panRecon state] == UIGestureRecognizerEnded /* || failed […]

保持横向模式的控制,但允许uitabbar切换

我有一个UITabBar开关的位置,当iphone改变方向和工作正常,但我希望在第一个标签的视图内的控件保持静态,无论手机的位置。 我觉得我失去了一些明显的东西? 编辑:基本上,控件总是风景,但标签栏必须切换方向。 这可能吗?

如何使用转换来旋转UIView

我有一个UIView ,我正在尝试使用您可以从coremotion态度获得的音高值进行转换(旋转)。 我正在使用转换,但我不知道我的代码是正确的,因为UIView没有做任何事情。 这是我的代码被称为每秒几次。 – (void)setLabelValueRoll:(double)roll pitch:(double)pitch yaw:(double)yaw { self.yLabel.text = [NSString stringWithFormat:@"pitch: %f", pitch]; CATransform3D transform; transform = CATransform3DMakeRotation(pitch + M_PI_2, 1, 0, 0); self.wapaA.layer.sublayerTransform = transform; } 诚实地说,我不确定如何设置这个部分(pitch + M_PI_2,1,0,0)来使得我的squar UIView的音高效果,所以当我们来回倾斜手机的时候,我会保持水平。 任何帮助,将不胜感激。

CGAffineTranformRotate atan2不准确

我正在进行我的视图转换,总是发生奇怪的事情,我的意思是我用这个代码计算angular度: angle = atan2f(currentTouchPoint.y – center.y, currentTouchPoint.x – center.x) – atan2f(previousTouchPoint.y – center.y, previousTouchPoint.x – center.x); 视图旋转但不正确。 我的意思是它在正确的方向旋转,但angular度总是不准确的+/- 0.05弧度。 而当我再次点击时,视图旋转到适当的位置 。 任何adivices? 逗号后的angular度精确到5个位置对我来说很重要。 Some NSLog to show you the problem: First rotation first tap and second tap 2012-01-07 01:01:26.283 Wheel[9080:707] Angle: 0.598412 2012-01-07 01:01:29.281 Wheel[9080:707] Angle: -0.070008 Second rotation first tap and second tap 2012-01-07 […]

iOS自定义视图:无法同时满足约束错误

我正在关注Ray Wenderlich关于实现rateView的教程: http ://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view 在我的应用程序中实现了rateView后,我得到了这个错误: 无法同时满足约束。 下面列表中的至less一个约束可能是你不想要的。 试试这个:(1)看看每一个约束,并试图找出你不期望的; (2)find添加不需要的约束或约束的代码并修复它。 (注意:如果您看到您不明白的NSAutoresizingMaskLayoutConstraints,请参阅UIView属性translatesAutoresizingMaskIntoConstraints的文档) (“NSAutoresizingMaskLayoutConstraint:0x870c2b0 h = – &v = – &V:[UIView:0x93a1d60(416)]”,“NSLayoutConstraint:0x87363c0 V:| – (203) – [RateView:0x8729040] UIView:0x93a1d60)“,”NSLayoutConstraint:0x8736440 V:[RateView:0x8729040] – (228) – |(Names:'|':UIView:0x93a1d60)“) 将尝试通过中断约束来恢复NSLayoutConstraint:0x8736440 V:[RateView:0x8729040] – (228) – | (名称:'|':UIView:0x93a1d60) 在objc_exception_throw上中断,在debugging器中捕获它。 UIKit / UIView.h中列出的UIView的UIConstraintBasedLayoutDebugging类中的方法也可能会有帮助。 我下载了Ray提供的示例应用程序,它对我来说是完美的,没有错误。 通过代码search后,我没有看到任何区别,我在Interface Builder中的连接与他的相同。 其中一个显着的区别是在我们的个人利率意见的大小督察。 他的样子是这样的: 而我的看起来像这样: 考虑到错误与约束有关,这可能是问题。 但是,我不知道如何改变我的rateview是自动调整和雷如。 帮帮我?