根据UIActionSheet的结果,我使用以下函数激活设备摄像机或图像选择器。如果是fromCamera=YES,那么它同时适用于iPhone和iPad。如果是fromCamera=NO,那么它在iPhone上工作,图像选择器就会出现。但是它在iPad上崩溃时有以下错误:UIStatusBarStyleBlackTranslucent在这个设备上不可用。iPad我已经知道iPad不能显示UIStatusBarStyleBlackTranslucent statusBar,但是如何避免这种崩溃呢?
-(void)addPhotoFromCamera:(BOOL)fromCamera{
if(fromCamera){
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else{
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:picker animated:YES];}
发布于 2011-09-19 13:55:08
我怀疑UIImagePicker继承了来自Info.plist文件或当前显示的视图控制器的半透明状态栏。
如果你让应用程序没有半透明的状态栏,会发生什么?
发布于 2012-04-17 13:51:35
如果在UIImagePickerControllerSourceTypePhotoLibrary上将选择器设置为iPad,则必须(!)将其呈现在弹出的概述中,否则会出现异常。我是这样做的,至少要控制罂粟的大小(我认为标准尺寸太小了):
-(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];
}为了对抗旋转错误,我还有以下几点:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if(imagePicker!=nil && rightPane.frame.size.width>0)
[imagePicker.view setFrame:imagePicker.view.superview.frame];
}它并不完美,但就我目前的测试目的而言,它是可以的。我考虑写我自己的Imagepicker,因为我不喜欢被强迫使用流行概述.但那是另一回事。
发布于 2011-10-20 17:59:26
https://stackoverflow.com/questions/7224243
复制相似问题