第12月第25天 ImagePickerSheetController
2017-09-25 17:52
183 查看
1.ImagePickerSheetController
https://github.com/allenwong/30DaysofSwift/
open class ImagePickerSheetController: UIViewController, UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIViewControllerTransitioningDelegate { ... lazy var backgroundView: UIView = { let view = UIView() view.backgroundColor = UIColor(white: 0.0, alpha: 0.3961) view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ImagePickerSheetController.cancel))) return view }() ... override open func loadView() { super.loadView() view.addSubview(backgroundView) view.addSubview(tableView) } ... // MARK: - Layout open override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() backgroundView.frame = view.bounds let tableViewHeight = Array(0..<tableView.numberOfRows(inSection: 1)).reduce(tableView(tableView, heightForRowAt: IndexPath(row: 0, section: 0))) { total, row in total + tableView(tableView, heightForRowAt: IndexPath(row: row, section: 1)) } tableView.frame = CGRect(x: view.bounds.minX, y: view.bounds.maxY-tableViewHeight, width: view.bounds.width, height: tableViewHeight) }
let authorization = PHPhotoLibrary.authorizationStatus() if authorization == .notDetermined { PHPhotoLibrary.requestAuthorization({ (status) -> Void in DispatchQueue.main.async(execute: { () -> Void in self.pickProfileImage(tap) }) }) } if authorization == .authorized { let controller = ImagePickerSheetController() controller.addAction(ImageAction(title: NSLocalizedString("Take Photo or Video", comment: "Action Title"), secondaryTitle: NSLocalizedString("Use this one", comment: "Action Title"), handler: { (_) -> () in self.presentCamera() }, secondaryHandler: { (action, numberOfPhotos) -> () in controller.getSelectedImagesWithCompletion({ (images) -> Void in self.profileImage = images[0] self.userProfileImageView.image = self.profileImage }) })) controller.addAction(ImageAction(title: NSLocalizedString("Cancel", comment: "Action Title"), style: .cancel, handler: nil, secondaryHandler: nil)) present(controller, animated: true, completion: nil) }
https://github.com/allenwong/30DaysofSwift/
相关文章推荐
- ios actionsheet 跟 imagepickercontroller冲突的问题解决方法
- customImagePickerViewController.overlayView
- 如何在ImagePickerController中只显示图片或者视频
- ZCImagePickerController框架简介
- JFImagePickerController、多选图片
- imagePickerController中info的对应的所有值
- 横屏下的ImagePickerController
- ELCImagePickerController
- 图片特效处理 DLCImagePickerController
- UI13_数据解析之图片相关(UIActionSheet,UIImagePickerController, UINavigationController协议方法)
- QBImagePickerController 下ALAsset ,PHAsset转图片的使用
- 不使用UIImagePickerControllerOriginalImage获取相册图片
- 如何在ImagePickerController中只显示图片或者视频?(既视频和图片的筛选)
- QBImagePickerController 用法
- 如何在ImagePickerController中只显示图片或者视频
- iOS7 弹出UIActionSheet,UIImagePickerViewController的navigationbar代理,搜索未用到的图片
- ImagePIckerController
- IOS - 使用 QBImagePickerController 从系统相册选取多张照片
- 使 ZCImagePickerController 支持预览功能
- iOS - 使用QBImagePickerController选取图片