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

问题描述

我有一个故事板,我在其中创建了一个 UINavigationController 实例,并将其自定义类设置为 UIImagePickerController

I have a storyboard where I created a UINavigationController instance and set its custom class to UIImagePickerController.

如果我在 prepareForSegue 中设置 imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera ,那么一切工作正常。

If I set imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera in prepareForSegue, everything works fine.

如果我在 prepareForSegue imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary c $ c>,我得到一个黑色大屏幕,顶部有一个空的灰色条,我无法解雇:

If I set imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary in prepareForSegue, I get a mostly black screen with an empty gray bar on top that I can't dismiss:

[截图的未来位置 - 我无法发布图片]

[future location of screenshot - I cannot post images]

我可以通过不使用故事板来解决这个问题。我的问题 - 这可以与故事板一起工作吗?如果没有,为什么不呢?为什么它只适用于展示相机?

I can work around this by not using the storyboard. The question I have-- can this be made to work with the storyboard? If not, why not? Why does it only work for presenting the camera?

编辑:一位同事评论说这可能是ios7的新问题

A colleague comments that this may be a new issue for ios7

如果segue由故事板触发,则下面的代码不起作用

The code below doesn't work if the segue is triggered by a storyboard

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSAssert([segue.destinationViewController isKindOfClass:[UIImagePickerController class]], @"Destination VC should be UIImagePickerController");

    UIImagePickerController *imagePicker = (UIImagePickerController*) segue.destinationViewController;

    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.allowsEditing = YES;
    imagePicker.delegate = self;

}


推荐答案

这个问题是

答案:

...似乎适用于大多数人,所以我我建议将此作为该问题的副本关闭,该问题已经回答了一段时间。

...appears to work for most people, so I've recommended this be closed as duplicate of that question which has been answered for awhile.

这篇关于故事板中的UIImagePickerController:UIImagePickerControllerSourceTypePhotoLibrary显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 04:46