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
}
}