I've got a UINavigationBar subclass to which I am adding some UIViews.
My UIViews are layed-out according to constraints I define in -[UIView updateViewConstraints:]
NSDictionary *views, *metrics;
// search container constraints
[self addSubview:self.searchContainer];
self.searchContainer.translatesAutoresizingMaskIntoConstraints = NO;
views = NSDictionaryOfVariableBindings(_searchContainer);
metrics = @{@"h": @(SearchContainerExpandedHeight) };
self.searchContainerLeftSpacingConstraint = [NSLayoutConstraint constraintWithItem:self.searchContainer attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:xMargin];
[self addConstraint:self.searchContainerLeftSpacingConstraint];
self.searchContainerRightSpacingConstraint = [NSLayoutConstraint constraintWithItem:self.searchContainer attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant: 0 - xMargin];
[self addConstraint:self.searchContainerRightSpacingConstraint];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-24-[_searchContainer(h)]" options:0 metrics:metrics views:views]];
//etc
On iOS8 and above, this works fine. On iOS7, I am getting the following error:
'Auto Layout still required after executing -layoutSubviews. MyUINavigationBarSubclass's implementation of -layoutSubviews needs to call super.'
What gives? I am not overriding layoutSubviews anywhere?
PS. I've tried calling [self layoutIfNeeded] before adding the constraints (as some have suggested in other questions) but it doesnt seem to work.