I've been trying to create a container view controller which provides some overlaid views like UINavigationController and UITabBarController do for view controllers in iOS 7. To make the contained views layout properly I've tried just about everything I can think of with regards to implementing -bottomLayoutGuide in both the container and contained view controllers, but with no luck. The method is called, but the value does not seem to be used.
I've put together a quick example at https://github.com/stefanfisk/custom-layout-guides, but there I was not able to even get the accessors called.
I've found that when you set up the constraints in code, e.g.
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:[topLayoutGuide][mainView]"
options:0
metrics:nil
views:@{@"topLayoutGuide" : self.topLayoutGuide, @"mainView" : self.mainView}]];
it crashes with:
2013-10-16 22:23:27.119 Custom Layout Guides[46840:a0b] -[LayoutGuide superview]: unrecognized selector sent to instance 0x8c80c80
2013-10-16 22:23:27.124 Custom Layout Guides[46840:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LayoutGuide superview]: unrecognized selector sent to instance 0x8c80c80'
It's weird that Auto Layout tries to call superview
on a layout guide, as it should only conform to the UILayoutSupport
protocol.
I've also noticed that topLayoutGuide
& bottomLayoutGuide
are declared as readonly
:
@property(nonatomic, readonly, retain) id<UILayoutSupport> topLayoutGuide
@property(nonatomic, readonly, retain) id<UILayoutSupport> bottomLayoutGuide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With