开发者

UINavigationController is overlapping a ModalViewController

开发者 https://www.devze.com 2023-02-04 09:46 出处:网络
I have an app which goes through a set of screens within a navigation controller, then there is a screen with a tab controller, which one of t开发者_如何学JAVAhe contained views wants to display a mod

I have an app which goes through a set of screens within a navigation controller, then there is a screen with a tab controller, which one of t开发者_如何学JAVAhe contained views wants to display a modal view controller that should be displayed over the top of the whole app (not full screen though).

It's all working fine, but the modal window is partially covered at the top by the navigation controller. I've tried using self / self.tabBarController / self.navigationController / self.tabBarController.navigationController to call presentModalViewController but they either don't work or still display the modal window underneath.

I've been searching for an answer to this all day, everyone else seems to have problems when it DOES overlap, not when it doesn't.

Any ideas? Thanks. (code, screenshots & video below)

- (IBAction)add:(id)sender {
  // create the view
  AddAttainmentController *addScreen = [[AddAttainmentController alloc] init];
  // pass in a selected pupil
  [addScreen setPupils:[NSMutableArray arrayWithObject:pupil]];
  // add the view to a navigation controller
  UINavigationController *control = [[UINavigationController alloc] initWithRootViewController:addScreen];
  // place the navigation controller on the screen
  [self presentModalViewController:control animated:YES];
  // release at the end
  [control release];
  [addScreen release];
}

Screenshots: http://cl.ly/032v2k0t0N1s1m3H0511 (you can see the navigation bar as the modal window slides in) http://cl.ly/1h0o453Y3Z051P3S1S37 (the navigation bar of the modal window is covered by the original)

Video: http://cl.ly/1e2J3o1q3V1l1j470m12


It sounds like you failed to consider some of the restrictions and assumptions around using Apple's view controller classes and are getting undefined and unexpected behavior as a result.

Tab bar controllers expect to always be at the root of your controller hierarchy. From the class reference:

When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller

Additionally modal view controllers (and all view controllers for that matter) are assumed to fill their window.

0

精彩评论

暂无评论...
验证码 换一张
取 消