I found that when you set restrictions in the code, for example
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topLayoutGuide][mainView]" options:0 metrics:nil views:@{@"topLayoutGuide" : self.topLayoutGuide, @"mainView" : self.mainView}]];
failure:
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 is strange that Auto Layout is trying to call superview in the layout guide, since it should only conform to the UILayoutSupport protocol.
I also noticed that topLayoutGuide and bottomLayoutGuide declared as readonly :
@property(nonatomic, readonly, retain) id<UILayoutSupport> topLayoutGuide @property(nonatomic, readonly, retain) id<UILayoutSupport> bottomLayoutGuide
Arek holko
source share