美文网首页
使用系统相册

使用系统相册

作者: 友田香菜 | 来源:发表于2018-01-17 22:30 被阅读8次
    image.png

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if indexPath.row == 0{
    guard UIImagePickerController.isSourceTypeAvailable(.photoLibrary) else{
    print("相册🙅‍♂️")
    return
    }
    let picker = UIImagePickerController()
    picker.allowsEditing = false
    picker.sourceType = .photoLibrary
    picker.delegate = self

            self.present(picker, animated: true, completion: nil)
        }
        
        tableView.deselectRow(at: indexPath, animated: true)
        
    }
    
    image.png

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    coverImageView.image = info[UIImagePickerControllerOriginalImage]as?UIImage
    coverImageView.contentMode = .scaleAspectFill
    coverImageView.clipsToBounds = true

        dismiss(animated: true, completion: nil)
    }
    
    image.png image.png

    相关文章

      网友评论

          本文标题:使用系统相册

          本文链接:https://www.haomeiwen.com/subject/yvrpoxtx.html