UIImagePickerController相机源问题 [英] UIImagePickerController Camera Source Problem

查看:84
本文介绍了UIImagePickerController相机源问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这是我编写的在相机源中显示UIImagePickerController的代码。我只是在属性的标题中声明了myPhotopicker并保留了它。在主代码文件中将其合成。然后调用选择器,我编写了以下代码:

Ok here is the code that I wrote to display the UIImagePickerController in the camera source. I just declared the myPhotopicker in the header for the property and retain it. Synthesized it in the main code file. Then calling the picker I wrote the code below:

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        if (myPhotopicker==nil) { 
            myPhotopicker = [[UIImagePickerController alloc] init];
            myPhotopicker.delegate = self; 
        }// create once!

        myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:myPhotopicker animated:NO];
}

在调用它时,应用中发生了一些奇怪的事情

Upon calling it, there are a few things that is weird happening to the app.


  1. 有时候,当后台运行许多应用程序(iPhone4)时,该应用程序将无法加载相机并使应用程序崩溃。虽然可以毫无问题地加载CameraRoll / PhotoAlbums。

  1. Sometimes, when there are many apps running in the background (iPhone4), the app would fail to load the camera and crash the app. Though it will load CameraRoll/PhotoAlbums without problem.

如果可以加载相机视图(当后台运行的应用较少时),请点击相机视图上的取消按钮将导致应用程序自身重新启动(快速显示Default.png图像,然后返回主页-就像我们启动应用程序时一样)。

If the camera view is able to load (when there are less apps running in the background), tapping the Cancel button on the camera view results in the app rebooting itself (where the Default.png image is shown quickly, and back to the main page - like when we started the app).

我一直在试图找出这个问题,但不确定该怎么做...请帮助。.谢谢。

I have been trying to figure out this problem, but not sure what to do... pls help.. Thanks.

推荐答案

而不是您的一次性创建逻辑尝试每次创建和释放。

Rather than your 'create once' logic try creating and releasing each time.

if ([UIImagePickerController  isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
     myPhotopicker = [[UIImagePickerController alloc] init];
     myPhotopicker.delegate = self;
     myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
     [self presentModalViewController:myPhotopicker animated:NO];
     [myPhotopicker release];
}

您还应该实现委托以在视图中从视图中删除模式视图控制器被关闭(如果尚未关闭)。

You should also implement the delegate to remove the modal view controller from view when it is dismissed (if you haven't already).

还应该检查当前类是否符合UINavigationConrollerDelegate协议。

You should also check that the current class conforms to the UINavigationConrollerDelegate protocol.

这篇关于UIImagePickerController相机源问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆