iOS --- 使用runtime解决3D Touch导致UIImagePicker崩溃的问题

UIImagePickerController是iOS中自带的系统相册选择器, 使用起来非常简便.

UIImagePickerController

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
// 设置sourceType为系统相册, 如果使用Camera请对应修改该属性.
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.allowsEditing = YES;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];

UIImagePickerController本身继承自UINavigationController, 因此不能将其简单视作一个UIViewController来看待.
了UINavigationControllerDelegate和UIImagePickerControllerDelegate协议, 包含了由三个ViewController组成的导航视图, 我们通过打印其viewControllers即可看出来:

(lldb) po [picker viewControllers]
<__NSArrayI 0x146b31140>(
    <PUUIAlbumListViewController: 0x14609a200>,
    <PUUIPhotosAlbumViewController: 0x1458e5a00>,
    <PUUIImageViewController: 0x1468f1ad0>
)

UIImagePickerControllerDelegate

UIImagePickerControllerDelegate协议有如下三个代理方法.

__TVOS_PROHIBITED @protocol UIImagePickerControllerDelegate<NSObject>
@optional
// The picker does not dismiss itself; the client dismisses it in these callbacks.
// The delegate will receive one or the other, but not both, depending whether the user
// confirms or cancels.
- (void)imagePickerController:(UIImagePickerControll
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值