iPad 弹出照片控制器失败
来源:互联网 发布:断电后mysql无法启动 编辑:程序博客网 时间:2024/05/21 08:40
iPad上选择照片情况:
我们会用actionSheet弹出一个选择器,点击选择项推出照片控制器但是ipad有一个问题是,在你将要推出照片选择器的时候,这个时候在controller上已经弹出了一个actionSheet,所以,系统会将你将要弹出的照片控制器进行取消操作。
解决办法:
在actionSheet的代理方法上,使用
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex这个方法进行操作
而不是- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex这个方法
这个情况是我遇见的:代码重现:
//弹出actionSheet选择器,并实现代理
- (void)chooseIconImage
{
UIActionSheet *actionSheet;
if([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
actionSheet =[[UIActionSheetalloc]
initWithTitle:@"选择一张图片"delegate:self
cancelButtonTitle:@"取消"destructiveButtonTitle:nil
otherButtonTitles:@"拍摄新照片",@"从图库中选择",nil];
}
else {
actionSheet =[[UIActionSheetalloc]
initWithTitle:@"选择一张图片"delegate:self
cancelButtonTitle:@"取消"destructiveButtonTitle:nil
otherButtonTitles:@"从图库中选择",nil];
}
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackOpaque];
[actionSheet showInView:[UIApplicationsharedApplication].keyWindow.rootViewController.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
UIImagePickerController *imagePickerController=nil;
if(buttonIndex != actionSheet.cancelButtonIndex)
{
if(!imagePickerController)
{
imagePickerController = [[UIImagePickerControlleralloc] init];
imagePickerController.delegate =self;
}
if(actionSheet.numberOfButtons==3)
{
imagePickerController.sourceType = (buttonIndex ==0) ?
UIImagePickerControllerSourceTypeCamera :UIImagePickerControllerSourceTypePhotoLibrary;
}
else
{
imagePickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
}
if(imagePickerController.sourceType ==UIImagePickerControllerSourceTypeCamera){
imagePickerController.allowsEditing =NO;
}
[selfpresentViewController:imagePickerControlleranimated:NOcompletion:nil];
}
}
//所以采用新的代理委托方法:也就是didDismissWithButtonIndex
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
UIImagePickerController *imagePickerController=nil;
if(buttonIndex != actionSheet.cancelButtonIndex)
{
if(!imagePickerController)
{
imagePickerController = [[UIImagePickerControlleralloc] init];
imagePickerController.delegate =self;
}
if(actionSheet.numberOfButtons==3)
{
imagePickerController.sourceType = (buttonIndex ==0) ?
UIImagePickerControllerSourceTypeCamera :UIImagePickerControllerSourceTypePhotoLibrary;
}
else
{
imagePickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
}
if(imagePickerController.sourceType ==UIImagePickerControllerSourceTypeCamera){
imagePickerController.allowsEditing =NO;
}
[selfpresentViewController:imagePickerControlleranimated:NOcompletion:nil];
}
}
- iPad 弹出照片控制器失败
- 用户开启了iCloud 照片库,选择了“优化 iPhone/iPad 储存空间”获取图片失败
- iPad开发 - UIPopoverController控制器
- Ipad照片丢失如何处理
- ipad弹出窗口
- iPad 横屏失败
- iOS开发 - 气泡控制器 IPAD
- 点击文字弹出照片
- ipad弹出中间设置界面
- Objective-C:Ipad弹出框
- ipad 上如何弹出UIActivityViewController
- iPad 6.0 Simulator 调用照片库Crash
- iPad越狱失败 越狱恢复
- ios-使用iPad专用API(UIPopoverController)控制器
- ios-使用iPad专用API(UISplitViewController)控制器
- iOS UIAlertController 弹出框控制器
- 硬盘占用,弹出失败
- ipad如何实现的弹出窗体
- POJ 2406
- error LNK2001: 无法解析的外部符号
- poj 3080 Blue Jeans
- poj 1724 Roads
- 双向队列
- iPad 弹出照片控制器失败
- BOM
- 编写docker-compose.yml需要注意的问题
- Html5 canvas生成图片,通过java进行保存
- java 使用全局过滤器Filter之后 防止css文件与js文件被过滤
- leetcode single Number
- python中*args **kwargs的使用
- logrotate使用
- Spring定时任务的几种实现