Reputation: 3619
I added a topLayoutGuide constraint to the superview of the navigation controller's view, then when I tried to change the frame of navigation controller's view, such as: from current frame of (0, 0, 320, 568) to (200, 0, 320, 568) using
[[navigationController view] setFrame:CGRectMake(200, 0, 320, 568)];
It's automatically set to the (0, 0, 320, 568) after the animation.
The topLayoutGuide constraint is added by this code :
- (void)viewDidLoad { // of subclassed UINavigationController class .m file
[super viewDidLoad];
// Do any additional setup after loading the view.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) {
[[self view] setTranslatesAutoresizingMaskIntoConstraints:NO];
id topGuide = [self topLayoutGuide];
UIView * selfView = [self view];
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (selfView, topGuide);
[[[self view] superview] addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topGuide]-0-[selfView]"
options:0
metrics:nil
views:viewsDictionary]];
[[[self view] superview] layoutSubviews]; // Must call this method here or the system raises an exception
}
}
Upvotes: 0
Views: 250
Reputation: 414
Autolayout strives to keep all constraints satisfied. After your animation this constraint becomes broken and in next layout cycle it will satisfy your constraint and change frame back. Consider animate layout constraint change or turn off autolayout.
Upvotes: 1