NSLayoutConstraints问题

时间:2014-08-04 08:42:48

标签: ios objective-c iphone

我已禁用xib的autolayout。但我正面临这个问题。即使我没有以编程方式添加任何子视图,并且我在此视图中有3个元素:

1。 UIImageView 2. UIButton 3. UIButton。

过去3天我受苦,但我无法找出错误。所以请任何人帮助我。我们将非常感谢您的帮助。

NSLog(@"Constratins %@",[self.view constraints]);
Constratins (
)


View hierarchy unprepared for constraint.
    Constraint: <NSAutoresizingMaskLayoutConstraint:0x294d9de0 h=-&- v=-&- UIViewControllerWrapperView:0x2d91c410.midY == UINavigationTransitionView:0xdd2aa40.midY>
    Container hierarchy: 
<UINavigationTransitionView: 0xdd2aa40; frame = (0 0; 1024 768); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0xdd2aca0>>
   | <UIViewControllerWrapperView: 0x2a72b4d0; frame = (0 0; 1024 768); layer = <CALayer: 0x2a72ab40>>
   |    | <UIView: 0x2d869b30; frame = (0 0; 1024 768); gestureRecognizers = <NSArray: 0x2d8852e0>; layer = <CALayer: 0x2d86b510>>
   |    |    | <MyImageView: 0x2d891040; baseClass = UIImageView; frame = (0 0; 1024 748); userInteractionEnabled = NO; layer = <CALayer: 0x2d8699f0>> - (null)
   |    |    | <UIButton: 0x2d88c460; frame = (968 14; 40 40); hidden = YES; opaque = NO; layer = <CALayer: 0x2d88c550>>
   |    |    | <UIButton: 0x2d88a220; frame = (963 9; 40 44); opaque = NO; layer = <CALayer: 0x2d88a310>>
    View not found in container hierarchy: <UIViewControllerWrapperView: 0x2d91c410; frame = (0 0; 1024 768); autoresize = W+H; layer = <CALayer: 0x2d91c490>>
    That view's superview: NO SUPERVIEW

1 个答案:

答案 0 :(得分:0)

是的,我找到了解决方案。原因是:没有设置 UIViewControllerWrapperView 的框架 所以我做了这个

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.tabBarController.view.superview.frame = self.view.bounds;
}