9

I have tab bar and in view "A" and in "A" I have navigation controller. SO inside my navigation controller in "A" i called

[self presentModalViewController:modalView animated:YES]

But modalView shows under tab bar. How to show it above tab bar?

Sergey Kuryanov
  • 6,114
  • 30
  • 52
Dmitriy Kalachniuk
  • 372
  • 1
  • 6
  • 25

4 Answers4

21

Try to present modal view from UITabBarController:

[self.tabBarController presentModalViewController:modalView animated:YES];
Sergey Kuryanov
  • 6,114
  • 30
  • 52
6

My case, the modal has a transparent background, I set modalPresentationStyle is .overFullScreen and it show at above tabbar with clear background.

QHu91_IT
  • 189
  • 2
  • 12
3

In my case the presented view controller had UIModalPresentationStyle.CurrentContext at .modalPresentationStyle, which made the tab bar overlap

Jus switch back to a default value to fix the issue

Tim
  • 1,877
  • 19
  • 27
  • Hey, Were you to able to solve this issue. I'm facing the same issue. :| – Yash Bedi Jan 18 '18 at 06:55
  • @YashBedi, yes, I set the modal presentation style to default one. In my case modal presentation style was changed from a default one by an accident – Tim Jan 18 '18 at 16:54
1

The cause of this is that the ancestor viewController is not correctly set. for instance imagine:

UIViewController * myController = ... // a view controller without a proper ancestor

now:

myController.tabBarController == nil

Therefore:

[myController presentModalViewController:otherController];

Will fail (by showing up under the tab bar). The fix is to add myController to its ancestor via

[parentController addChildViewController:myController];

Now, parentController must be added to another controller in the same way and so forth until the root one is your tabController. This is only available in iOS 5+. If build for iOS 4 or earlier, you will have to work around this by making sure all of your controllers are directly added to either a UINav or UITab controller. If this is not possible, you will have to access the UITabBarController via a global variable.

George
  • 1,457
  • 11
  • 26