Jason Renaldo
Jason Renaldo

Reputation: 2822

UINavigationBar resizes and covers UIViews

We instanitate a UINavigationController and a UIViewController from a storyboard like so:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"AddOrder" bundle:nil];
UIViewController *vc = [sb instantiateInitialViewController];
UIViewController *topVC = ((UINavigationController *) vc).topViewController;

vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];

enter image description here

From here, it looks like the UIViewController isn't taking up the whole UIWindow, it looks 20 pts down like on ios6. You can even see the underlying UISplitViewController's divider at the top left if you look closely.

The issue is, when the user taps an option on the UITableView on theUIViewController we call [self performSegueWithIdentifier: sender:] which pushes a new UIViewController on, but when they rotate it, it looks like so:

enter image description here

A little cramped, to say the least. But now, when we go back to the first UIViewController and rotate, we get this:

enter image description here

Issue is, the search bar is now covered. You'll notice you cannot see the underlying UISplitViewController anymore either. As you can see, it looks like now the UINavigationBar is covering up the other 20 pts and is larger in height.

I kind of "fixed" the issue by calling self.edgesForExtendedLayout = UIRectEdgeNone; but that just shoves the UIView pretty far down. I also toyed with adding [UIViewController attemptRotationToDeviceOrientation] but nothing. In Apple's HIG it states that a navigation bar should not change it's height on the iPad, yet this is happening to me when I log out the frame.

Any ideas?

Upvotes: 2

Views: 226

Answers (2)

souvickcse
souvickcse

Reputation: 7804

Hi You can create the view controller with these properties enter image description here

And add the modal on the the application window

[self.view.window.rootViewController presentViewController:vc animated:YES completion:nil];

I think your problem will be solved by this.

Upvotes: 1

iPatel
iPatel

Reputation: 47099

Just fix it by

self.automaticallyAdjustsScrollViewInsets = NO; 

Put this line in viewDidLoad method and then create other controllers.

It's only working on iOS 7 and latter.

Upvotes: 0

Related Questions