带有iAds的ECSlidingViewController

时间:2014-01-06 20:40:06

标签: ios autolayout ecslidingviewcontroller

我正在使用带有左侧和右侧的ECSlidingViewController;右侧菜单。

尝试让iAd显示在整个应用的底部。我的StoryBoard入口点是一个ViewController,它是一个ECSlidingViewController子类。

故事板设置为AutoLayout以及我的所有其他代码。

当我将self.canDisplayBannerAds = YES;添加到viewWillAppear时,构建失败并显示:

    View hierarchy unprepared for constraint.
    Constraint: <NSAutoresizingMaskLayoutConstraint:0xb2a9030 h=--- v=--- UIView:0xa499b70.midX == UIView:0xa4a95f0.midX>
    Container hierarchy: 
<UIView: 0xa4a95f0; frame = (0 0; 768 1024); layer = <CALayer: 0xa4a84d0>>
    View not found in container hierarchy: <UIView: 0xa499b70; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0xa499380>>
    That view's superview: <UIWindow: 0xb263e30; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0xb264f30>; layer = <UIWindowLayer: 0xb264080>>
2014-01-06 20:22:15.772 AppTest[10851:a0b] View hierarchy unprepared for constraint.
    Constraint: <NSAutoresizingMaskLayoutConstraint:0xb2a9180 h=--- v=--- UIView:0xa499b70.width == UIView:0xa4a95f0.width>
    Container hierarchy: 
<UIView: 0xa4a95f0; frame = (0 0; 768 1024); layer = <CALayer: 0xa4a84d0>>
    View not found in container hierarchy: <UIView: 0xa499b70; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0xa499380>>
    That view's superview: <UIWindow: 0xb263e30; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0xb264f30>; layer = <UIWindowLayer: 0xb264080>>
2014-01-06 20:22:15.772 AppTest[10851:a0b] View hierarchy unprepared for constraint.
    Constraint: <NSAutoresizingMaskLayoutConstraint:0xb2a92b0 h=--- v=--- UIView:0xa499b70.midY == UIView:0xa4a95f0.midY>
    Container hierarchy: 
<UIView: 0xa4a95f0; frame = (0 0; 768 1024); layer = <CALayer: 0xa4a84d0>>
    View not found in container hierarchy: <UIView: 0xa499b70; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0xa499380>>
    That view's superview: <UIWindow: 0xb263e30; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0xb264f30>; layer = <UIWindowLayer: 0xb264080>>
2014-01-06 20:22:15.815 AppTest[10851:a0b] View hierarchy unprepared for constraint.
    Constraint: <NSAutoresizingMaskLayoutConstraint:0xb2a92e0 h=--- v=--- UIView:0xa499b70.height == UIView:0xa4a95f0.height>
    Container hierarchy: 
<UIView: 0xa4a95f0; frame = (0 0; 768 1024); layer = <CALayer: 0xa4a84d0>>
    View not found in container hierarchy: <UIView: 0xa499b70; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0xa499380>>
    That view's superview: <UIWindow: 0xb263e30; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0xb264f30>; layer = <UIWindowLayer: 0xb264080>>
2014-01-06 20:22:15.815 AppTest[10851:a0b] View hierarchy unprepared for constraint.
    Constraint: <NSAutoresizingMaskLayoutConstraint:0xb2a9030 h=--- v=--- UIView:0xa499b70.midX == UIView:0xa4a95f0.midX>
    Container hierarchy: 
<UIView: 0xa4a95f0; frame = (0 0; 768 1024); layer = <CALayer: 0xa4a84d0>>
    View not found in container hierarchy: <UIView: 0xa499b70; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0xa499380>>
    That view's superview: <UIWindow: 0xb263e30; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0xb264f30>; layer = <UIWindowLayer: 0xb264080>>
2014-01-06 20:22:15.838 AppTest[10851:a0b] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view.  Does the constraint reference something from outside the subtree of the view?  That's illegal. constraint:<NSAutoresizingMaskLayoutConstraint:0xb2a9030 h=--- v=--- UIView:0xa499b70.midX == UIView:0xa4a95f0.midX> view:<UIView: 0xa4a95f0; frame = (0 0; 768 1024); layer = <CALayer: 0xa4a84d0>>'

看起来我需要在某处添加约束,因为当显示iAd时高度会改变。

2 个答案:

答案 0 :(得分:1)

首先,在显示视图之前设置canDisplayBannerAds(即加载视图时)。

其次,更新视图,使其没有自动转换的自动调整大小约束(请参阅translatesAutoresizingMaskIntoConstraints)。

答案 1 :(得分:0)

我认为您遇到的问题是您正在尝试调整ECSlidingViewController的子视图的大小。您应该改为调整ECSlidingViewController的视图。

我会创建一个容器视图控制器并将其作为入口点。子视图将是iAd视图和ECSlidingViewController的视图。