UIImagePickerController显示黑色预览屏幕 [英] UIImagePickerController Showing Black Preview Screen

查看:82
本文介绍了UIImagePickerController显示黑色预览屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用UIImagePickerController使用相机时出现问题.有时,但比没有任何时候更频繁,预览屏幕显示为黑色(因为相机本身被遮盖了).经过一些研究,似乎人们没有正确地委派它..但是,我相信我的设置是正确的.重新启动应用程序即可解决此问题.

I am having a problem when calling the UIImagePickerController to use the camera. Sometimes, but more often than none, the preview screen shows to be black (as the camera itself is covered). After doing some research, it seems that people where not delegating it correctly..however, I believe my set up is correct. A restart of the app is what fixes it.

在我的.h文件中,我包含了UIImagePickerControllerDelegate和UINavigationControllerDelegate.

In my .h file I have included UIImagePickerControllerDelegate and UINavigationControllerDelegate.

这是.m文件的代码

- (IBAction)camera:(id)sender {
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

    #if TARGET_IPHONE_SIMULATOR
        imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    #else
        imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    #endif
        imagePickerController.editing = YES;
        imagePickerController.delegate = self;
        [self presentViewController:imagePickerController animated:YES completion:nil];
    }

关于为什么发生这种情况的任何想法吗?

Any ideas as to why this is happening?

谢谢

推荐答案

尝试一下.它解决了我的问题,请确保其中有一个值

Try this. it solved my problem, make sure that there is a value

(应用程序名称为字符串)在info.plist>"捆绑显示名称"中.

(Application name as string) in your info.plist > "Bundle display name".

在我的情况下,它是空的,因此它不起作用.

In my case it was empty and because of that it didn't work.

如果info.plist中没有"捆绑显示名称",则添加名为捆绑显示名称"的行并粘贴您的应用名称.

If "Bundle display name" is not there in the info.plist,then add a row named "Bundle display name" and paste your appname .

这篇关于UIImagePickerController显示黑色预览屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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