iPhone - ModalViewController not raising to top of

2019-07-25 08:26发布

问题:

I have a UIImagePickerController that is shown

[self presentModalViewController:self.picker animated:NO];

Then later on the code, I allow the user to display a preference panel :

PreferencesController *nextWindow = [[[PreferencesController alloc] initWithNibName:@"Preferences" bundle:nil] autorelease];
UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:nextWindow] autorelease];
[self presentModalViewController:navController animated:YES];

At this point, the new controller raises on the screen, but don't go to the top. Some space is left "transparent" at the top (I can see the camera view behind), and the bottom of the view is hidden out of the screen. The space I am talking about is about a status bar height. The status bar is not present on the screen.

The navigation controller is hidden :

self.navigationController.navigationBarHidden = YES;

There is a toolbar at the top of the view. Nothing special into the view. The height of the view is defined at 480. All simulated element are set off in IB. The autoresize properties are all set on.

I had a previous xib (I rebuilt it from scratch) that worked very well. I don't see what I missed on this one (I have only changed the xib, that replaces the previous one).

I've cleaned the cache to be sure there was nothing left. No change... I've deleted everything in the new view to prevent some conflicts. No change...

What did I miss ? How could I remove this empty space ?

回答1:

Try presenting the second modal view controller (the preferences one) from self instead of self.picker

ModalViewController loading on top of another Modal

Edit:

Try setting wantsFullScreenLayout = YES



回答2:

After some searches and some other problems, I've found a final solution to the problem through this question

I had to call :

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

at the application start.