1

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 ?

Oliver
  • 23,072
  • 33
  • 138
  • 230

2 Answers2

2

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

Community
  • 1
  • 1
Zaky German
  • 14,324
  • 4
  • 25
  • 31
  • @Zaky German : When using the direct method of call shown in your link, my Tollbar buttons don't work anymore. So I keep using an intermediate UINavigationController (as shown). But calling with just 'self' works. I keep it. But previously, I was calling the new view from the picker, and everything was working fine. Not space problem – Oliver Mar 16 '11 at 23:58
  • @Zaky German : When calling from self, after the new view has gone up, I see my overlay behind going down to the top of the new view. When I dismiss the view, the overlay keeps at this 'downed' position. – Oliver Mar 17 '11 at 00:02
  • @Oliver In the new XIB you've created, select the top level UIView, enter the inspector, and in the View attributes check if Status Bar is Unspecified. I've had similar errors when those attributes weren't correctly set and it invites weird behavior... – Zaky German Mar 17 '11 at 00:04
  • @Zaky German : No, it isn't. And I've adjusted the height to 480 (It is left at 460 when you unspecify the status bar). – Oliver Mar 17 '11 at 00:05
  • @Oliver Well did setting it to Unspecified and fixing the view get you any closer to a solution? – Zaky German Mar 17 '11 at 00:11
  • @Zaky German : it wasn't set already (see my post). So no more closer or more far from the solution... I've tried to set it back to "status bar on" and then off, to see if that changed something, but no change. I don't understand why this happens. It was working fine before with the previous xib... – Oliver Mar 17 '11 at 00:14
  • @Zaky German : I'm going mad. I've unzipped my saved project and inspected the previous xib. It's exactly the same ! – Oliver Mar 17 '11 at 00:18
  • @Oliver Did you try to hack the frame? Like setting the y to -20 or something, if that would be acceptable as a solution :) – Zaky German Mar 17 '11 at 00:19
  • @Zaky German : I have a strange behaviour... When asking to see where my old xib from the old project is in the finder, it is shown... into the xcodeproj file (yes, you've read well) with its controller (.m and .h). In my new project, it is into the project folder. – Oliver Mar 17 '11 at 00:22
  • @Zaky German : No, I won't hack the frame as it is supposed to work fine, and woked fine before. – Oliver Mar 17 '11 at 00:22
  • @Oliver well that's another issue, fix it by deleting the reference (do not delete file when prompted to) from the XCode Groups & Files then dragging the correct one to the project again. – Zaky German Mar 17 '11 at 00:25
  • @Zaky German : replacing the old xib with the new one. Launching the old project. Clean, build, run : whitespace... – Oliver Mar 17 '11 at 00:31
  • @Oliver did you try it without the navigation view controller after applying the this instead of this.picker fix? – Zaky German Mar 17 '11 at 00:32
  • @Zaky German : opening the old project. Keeping the view and the toolbar, but replacing the old content of the view with the new one... Clean, build, run... That works... No white space... But... pictures that are not in my old project are shown into the new content... And not visible of course in IB. I'm going really crazy !!! – Oliver Mar 17 '11 at 00:36
  • @Zaky German : I've played for hours and hours with the navigation controllers. Calling the view without the navigation controller dont works or make buttons don't work into the toolbar. – Oliver Mar 17 '11 at 00:37
  • 1
    @Oliver if the new project has the same bundle identifier the application will simply be overwritten with the same documents and such in the simulator/device – Zaky German Mar 17 '11 at 00:38
  • @Zaky German : Ooops, I said it works, but... the new content in the old xib is a bit pushed down. Let's say... a status bar height... But no white space... I'd really like to solve this thing into the new project. Deleting the old unzipped one. – Oliver Mar 17 '11 at 00:40
  • 1
    @Oliver try setting the wantsFullScreenLayout of both preferences controller and the navigation controller to YES – Zaky German Mar 17 '11 at 00:42
  • @Zaky German : I've put wantsFullScreenLayout=YES one after one to any navigationController I've met, from down to top (Preferences to picker), and nothing changed. – Oliver Mar 17 '11 at 00:47
  • did you give it to the navController that contains the nextWindow as well? – Zaky German Mar 17 '11 at 00:48
  • @Zaky German : Excuse my Zaky, but it's 2 here and I'm starting to be tired tonight. I've planned to make some minor changes to a xib in 10 minutes, and I'm going to spend hours and hours to solve a problem that was not there before... just to show a view. May we continue this investigation tomorrow if you please ? – Oliver Mar 17 '11 at 00:49
  • @Zaky German : yes, I gave it to the navController that contains the nextWindow as well – Oliver Mar 17 '11 at 00:50
  • @Oliver Sure, it's 3 here as well :) Many times just going to sleep gives you the answer the next day heh. Now i'm wondering how do you private message here... – Zaky German Mar 17 '11 at 00:54
  • @Zaky German : I've claned 3 times my project, moved some items in the xib to see well the top and bottom limits. Deleted the app from the device. The... self.picker now make me appear a strange window names "Item", with nothing in the view except a toolbar with an action button on the right. Going back to call the controller with just self. And this works !!! But... when going back from the preferences view, my overlay has gone donw from a status bar height. I propose we continue from this point tomorrow, as the preferences view is now ok with that method – Oliver Mar 17 '11 at 01:14
  • (but I still don't see what was going wrong, my code is the same... Just moved some items in the preferences xib onto the view...) – Oliver Mar 17 '11 at 01:15
  • You know what ??? I just replaced back the items on the xib to their good places, and the problem is back. And the overlay still pushed down... And I can't use self.picker anymore to raise the view because of that strange view appearing instead of my cameraview. I don't think that sleep will help... :-( – Oliver Mar 17 '11 at 01:18
  • @Zaky German : You where right : it was a problem of wantsFullScreenLayout = YES. I put it on the overlay (self.overlay.wantsFullScreenLayout = YES;) and on the window of the preferences (nextWindow.wantsFullScreenLayout = YES;) and it works fine. I don't understand why this didn't work the last time I did it... Perhaps too much wantsFullScreenLayout at different places chere conflicting... Could you post your comment as an answer as I could accept it ? Thank you very much for your help on this problem. Really. – Oliver Mar 17 '11 at 23:07
  • @Zaky German : Hello, Thank you for the edit. But in fact, that caused some further problems. In fact, the statusBar must be hidden at the start of the application as I mentioned in my answer bellow. Then no more need to set wantsFullScreen at all anywhere. – Oliver Mar 20 '11 at 00:31
0

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.

Community
  • 1
  • 1
Oliver
  • 23,072
  • 33
  • 138
  • 230