iPhone camera can't open from landscape application

给你一囗甜甜゛ 提交于 2019-12-11 15:18:17

问题


I am creating a landscape only application using sdk 3.0 that uses mapkit. I need to use iphone camera in my application. But I am getting following warning when I try to open camera.

"Can't perform full-screen transition. The fromViewController's view must be within a view that occupies the full screen."

The view from which I am calling camera method is mapview with size of 480*320. I have written following code to call camera:

UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;

picker.sourceType=UIImagePickerControllerSourceTypeCamera;

[self presentModalViewController: picker animated:YES];
[picker release];

After that I have written the usual method :

-(void)imagePickerController : (UIImagePickerController *)picker didFinishPickingImage : (UIImage *)image  editingInfo : (NSDictionary *)editingInfo

But this is never called , since camera is never opened. So my question is what am I missing here...? I am testing this app on actual iphone device , not on simulator. I have used this code in another app and it works fine. But here, it simply doesnt work! Plz help if you have any idea about this..


回答1:


it sounds like the warning is telling you the problem: the parent view you're passing in to presentModalViewController needs to be a full-screen view. So instead of using "self" in this code you need to use something else, like the parent view controller.

now, you're going to have another problem, because the camera controller doesn't like landscape mode, so you may have to switch back to portrait mode before showing it....




回答2:


just replace "self" with the parent ViewController which is probably declared in you appDelegate.



来源:https://stackoverflow.com/questions/1225934/iphone-camera-cant-open-from-landscape-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!