第12月第25天 ImagePickerSheetController

Posted lianhuaren

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第12月第25天 ImagePickerSheetController相关的知识,希望对你有一定的参考价值。

1.ImagePickerSheetController

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/

以上是关于第12月第25天 ImagePickerSheetController的主要内容,如果未能解决你的问题,请参考以下文章

第25月第7天 聚宽 svm

第25月第4天 djangochinaorg项目记录01

第25月第2天 django项目01

第25月第6天 李宏毅 深度学习

第25月第26天 dispatch_group

第13月第25天 ios11 uitableview reloaddata contentsize