永发信息网

ios中跳转到本地相册右上的取消按钮怎么设置

答案:1  悬赏:70  手机版
解决时间 2021-11-13 07:55
  • 提问者网友:献世佛
  • 2021-11-13 04:42
ios中跳转到本地相册右上的取消按钮怎么设置
最佳答案
  • 五星知识达人网友:舊物识亽
  • 2021-11-13 04:49
使用iOS开发原生技术:UIImagePickerController
(1)创建相册视图控制器
UIImagePickerController *imagePickVC = [[UIImagePickerController alloc] init];

// 设置代理对象

imagePickVC.delegate = self;

// 开启编辑模式

imagePickVC.allowsEditing = YES;

// 设置媒体类型

imagePickVC.mediaTypes = @[@"public.image"];

(2)判断打开的是相册还是摄像航头

if (buttonIndex == 0) {

imagePickVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

} else if (buttonIndex == 1) {

// 要打开摄像头

if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront] || [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {

imagePickVC.sourceType = UIImagePickerControllerSourceTypeCamera;

} else {

iToast *itoast = [iToast makeText:@"当前设备不支持拍摄"];

[itoast show];

return;

}

}

(3)打开系统相册

[self presentViewController:imagePickVC animated:YES completion:nil];
(4)实现代理方法
//点击相册的取消按钮

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:nil];

}
//照片处理方法

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯