UIImagePickerController

UIImagePickerController

本文介绍了UIImagePickerController出现但摄像头无法在iOS 5上启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我提供 UIImagePickerController ,源类型 UIImagePickerControllerSourceTypeCamera 。一切正常,除非我离开应用程序并返回(启用多任务处理以便应用程序返回到它停止的位置)并再次呈现 UIImagePickerController 。它出现在屏幕上,但相机从未显示,相机显示的动画永远不会发生,这里是截图:

I have an app where I present a UIImagePickerController with source type UIImagePickerControllerSourceTypeCamera. Everything works fine unless I leave the app and come back (multitasking is enabled so the app comes back right where it left off) and I present the UIImagePickerController again. It appears on screen but the camera never shows, the animation where the camera is revealed never happens, here is a screenshot:

如果我再次按下取消并再次显示 UIImagePickerController ,相机将显示正常。所以这个问题发生的唯一时间是我第一次在回到应用程序后呈现 UIImagePickerController 。任何人都知道为什么会这样吗?我正在为iOS 5编码

If I press cancel and present the UIImagePickerController again, the camera will show up fine. So the only time this problem occurs is the first time I present the UIImagePickerController after coming back to the app. Anyone know why this is happening? I'm coding for iOS 5

我正在使用以下内容呈现 UIImagePickerController

I'm presenting the UIImagePickerController with:

[self presentViewController:capturePhotoPicker animated:YES completion:nil];

并将其解雇:

[self dismissViewControllerAnimated:YES completion:nil];

我使用相同的 UIImagePickerController 对象我给它的时间

I am using the same UIImagePickerController object each time I present it

推荐答案

如果你将 - (void)viewDidLoad改为 - (void)viewDidAppear:(BOOL)动画它解决了这个问题。我花了最近两周的时间试图解决这个问题

if you change the -(void)viewDidLoad to - (void)viewDidAppear:(BOOL)animated it fixes the problem. I've spent the last 2 weeks trying to figure this out

这篇关于UIImagePickerController出现但摄像头无法在iOS 5上启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 20:02