Reputation: 5181
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?
Upvotes: 5
Views: 1419
Reputation: 521
Call
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Before calling
[self presentModalViewController:picker animated:YES]
Upvotes: 0
Reputation: 2561
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.
Upvotes: 0
Reputation: 1
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];
Upvotes: -1
Reputation: 5181
After lots of tries, I discovered that calling presentViewController from the [[[[UIApplication sharedApplication] delegate] window] rootViewController]
solved the problem.
Upvotes: 3
Reputation: 4762
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?
Upvotes: 0
Reputation: 4415
Some code would be helpful.
If relevant, try setting the bounds
property instead of the frame
property.
Upvotes: 0
Reputation: 38239
You should change the frame property of imagePickerController. when intializing I.e.
imagePickerController.view.frame.origin.y = 20;
Upvotes: 0