首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >崩溃iPad照片选择器

崩溃iPad照片选择器
EN

Stack Overflow用户
提问于 2011-08-28 21:57:19
回答 3查看 3.8K关注 0票数 9

根据UIActionSheet的结果,我使用以下函数激活设备摄像机或图像选择器。如果是fromCamera=YES,那么它同时适用于iPhone和iPad。如果是fromCamera=NO,那么它在iPhone上工作,图像选择器就会出现。但是它在iPad上崩溃时有以下错误:UIStatusBarStyleBlackTranslucent在这个设备上不可用。iPad我已经知道iPad不能显示UIStatusBarStyleBlackTranslucent statusBar,但是如何避免这种崩溃呢?

代码语言:javascript
复制
-(void)addPhotoFromCamera:(BOOL)fromCamera{

if(fromCamera){    
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else{
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}


[self presentModalViewController:picker animated:YES];

}

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-09-19 13:55:08

我怀疑UIImagePicker继承了来自Info.plist文件或当前显示的视图控制器的半透明状态栏。

如果你让应用程序没有半透明的状态栏,会发生什么?

票数 3
EN

Stack Overflow用户

发布于 2012-04-17 13:51:35

如果在UIImagePickerControllerSourceTypePhotoLibrary上将选择器设置为iPad,则必须(!)将其呈现在弹出的概述中,否则会出现异常。我是这样做的,至少要控制罂粟的大小(我认为标准尺寸太小了):

代码语言:javascript
复制
-(void)openPhotoPicker
{
    imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.navigationBar.opaque = true;

    //put the image picker in its own container controller, to control its size
    UIViewController *containerController = [[UIViewController alloc] init];
    containerController.contentSizeForViewInPopover = rightPane.frame.size;
    [containerController.view addSubview:imagePicker.view];

    //then, put the container controller in the popover
    popover = [[UIPopoverController alloc] initWithContentViewController:containerController];

    //Actually, I would like to do the following, but iOS doesn't let me:
    //[rightPane addSubview:imagePicker.view];

    //So, put the popover over my rightPane. You might want to change the parameters to suit your needs.
    [popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 10.0,0.0) 
                     inView:rightPane
    permittedArrowDirections:UIPopoverArrowDirectionLeft
                   animated:YES];

    //There seems to be some nasty bug because of the added layer (the container controller), so you need to call this now and each time the view rotates (see below)
    [imagePicker.view setFrame:containerController.view.frame];
}

为了对抗旋转错误,我还有以下几点:

代码语言:javascript
复制
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    if(imagePicker!=nil && rightPane.frame.size.width>0)
        [imagePicker.view setFrame:imagePicker.view.superview.frame];
}

它并不完美,但就我目前的测试目的而言,它是可以的。我考虑写我自己的Imagepicker,因为我不喜欢被强迫使用流行概述.但那是另一回事。

票数 4
EN

Stack Overflow用户

发布于 2011-10-20 17:59:26

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7224243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档