I have a navigation controller on which i am adding on a UIViewController in the following way
UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:self.homeViewController];
_centerViewNavigaionController = navController;
if (bIsDeviceOSVersion7) {
_centerViewNavigaionController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
else
{
_centerViewNavigaionController.view.frame = CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height+20);
}
[self.view addSubview:navController.view];
[self addChildViewController:navController];
It is working fine in iOS 7 but in iOS6 - HomeViewController (ie RootViewController of this navigation controller) loads fine. But when i push a new View Controller onto HomeViewController ie RootViewController the new view frame moves up by 20 pixels only the fist time. Next time when its pushed it works fine. I looked up on stack overflow but not able to resolve this issue. How can i fix this?
Instead of doing this
_centerViewNavigaionController.view.frame = CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height+20);
you can just set the delta property through Interface Builder for the immediate view/views under viewcontroller object. or else you must use Autolayout to avoid such things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.