I am calling a UIImagePickerController (sourceTypeCamera) as a modalViewController from my MainViewController.
However, the UIImagePickerController doesn't fill the screen on top, as the image attached shows.
Any idea what can be causing this, and how to fix?
-
1This isn't in any way expected behavior for calling up a simple picker, please attach the code for how you are presenting it so we can better understand the problem. – Mick MacCallum Jun 14 '12 at 13:23
-
@natan: Only at the top u have a black bar or also at the bottom u have one? I think u also have a black bar at the bottom, but have hidden it with the toolbar. Is that right? – The X-Coder May 15 '13 at 06:47
7 Answers
After lots of tries, I discovered that calling presentViewController from the [[[[UIApplication sharedApplication] delegate] window] rootViewController]
solved the problem.

- 5,141
- 1
- 31
- 48
-
2I still have the same problem when using [[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:videoRecorder animated:YES completion:^{}]; or [self.window.rootViewController presentModalViewController:videoRecorder animated:YES]; from the AppDelegate class – richy Dec 20 '12 at 00:29
-
You should change the frame property of imagePickerController. when intializing I.e.
imagePickerController.view.frame.origin.y = 20;

- 38,095
- 11
- 81
- 132
Some code would be helpful.
If relevant, try setting the bounds
property instead of the frame
property.

- 4,075
- 1
- 25
- 32
In my application in a viewcontroller which is inside navigationController - i'm doing simply like this:
UIImagePickerController* imagePickerController_;
imagePickerController_.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePickerController_ animated:YES];
and
@interface CustomViewController : UIViewController <UIImagePickerControllerDelegate>
Works without problems. If You still have problems, then can you please share some code? what kind of navigation structure your application have (tabbarcontroller, navigationcontroller, .. ?)?, how do you present imagepickercontroller?

- 4,764
- 2
- 50
- 72
There is a boolean on UIViewController that may be of use to you: wantsFullScreenLayout
. According to the docs, this is:
A Boolean value indicating whether the view should underlap the status bar.
I've had several issues, especially on iOS 5, with views underlapping the status bar, especially when presented modally. The best thing I have found is to set this value to YES
, and manually lay out your view below the status bar. FYI, the status bar has a height of 20.

- 2,501
- 22
- 28
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self.view addSubview:imagePicker.view];
[imagePicker viewWillAppear:YES];
[imagePicker viewDidAppear:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];

- 1,406
- 4
- 20
- 39