Good day, friends!
I'm currently developing my first app and I can't get through one issue with auto layout. I have to set up constraints between two buttons. But they have to be changing depending on the resolution of display: not a constant offset.
As far as I understand, I can't do it in IB, so I've built constraints programmatically with code like this:
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|-horizontalOffset-[button1(>=102)]-buttonsInterval-[button2(>=102)]-horizontalOffset-|"
options:0
metrics:metrics
views:buttons]];
It works fine if I create buttons in code, but it doesn't work if buttons are created in storyboard. I do the update here:
- (void)updateViewConstraints
{
[super updateViewConstraints];
[self setMyConstraintsForScreen:self.view];
}
But there always are some conflicts with previously created constraints for this buttons - either xcode creates them by itself or I set them up manually in IB.
When I try to delete all constraints from the root view, I have this error:
'The layout constraints still need update after sending -updateViewConstraints to <ViewController: 0x7ffa6a5497c0>.
ViewController or one of its superclasses may have overridden -updateViewConstraints without calling super or sending -updateConstraints to the view. Or, something may have dirtied layout constraints in the middle of updating them. Both are programming errors.'
I do call [super updateViewConstraints] though... I don't send updateViewConstraints to any particular view either.
Does anyone have a solution? Basically I need to do a simple thing: set up variable constraints for the view built in storyboard.
Thanks!