Privacy - Photo Library Usage Description 和 Privacy - Camera Usage Description ,都是String类型,内容任意的字符串即可。
2.UIImagePickerControllerDelegate,UINavigationControllerDelegate
3.//底部弹窗
func popupView(){
var alert: UIAlertController!
alert = UIAlertController(title: "提示", message: "添加照片", preferredStyle: UIAlertControllerStyle.actionSheet)
let cleanAction = UIAlertAction(title: "取消", style: UIAlertActionStyle.cancel,handler:nil)
let photoAction = UIAlertAction(title: "拍照", style: UIAlertActionStyle.default){ (action:UIAlertAction)in
self.camera()
}
let choseAction = UIAlertAction(title: "从手机相册选择", style: UIAlertActionStyle.default){ (action:UIAlertAction)in
self.photo()
}
alert.addAction(cleanAction)
alert.addAction(photoAction)
alert.addAction(choseAction)
self.present(alert, animated: true, completion: nil)
}
//调用照相机方法
func camera(){
let pick:UIImagePickerController = UIImagePickerController()
pick.delegate = self
pick.sourceType = UIImagePickerControllerSourceType.camera
self.present(pick, animated: true, completion: nil)
}
//调用照片方法
func photo(){
let pick:UIImagePickerController = UIImagePickerController()
pick.delegate = self
pick.sourceType = UIImagePickerControllerSourceType.photoLibrary
self.present(pick, animated: true, completion: nil)
}