Pregunta

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. UIImagePickerController strange behavior Any idea what can be causing this, and how to fix?

¿Fue útil?

Solución

After lots of tries, I discovered that calling presentViewController from the [[[[UIApplication sharedApplication] delegate] window] rootViewController] solved the problem.

Otros consejos

You should change the frame property of imagePickerController. when intializing I.e.

imagePickerController.view.frame.origin.y = 20;

Some code would be helpful.

If relevant, try setting the bounds property instead of the frame property.

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?

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.

Call

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

Before calling

[self presentModalViewController:picker animated:YES]
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];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top