获取相机(swift)

前端之家收集整理的这篇文章主要介绍了获取相机(swift)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

获取相机(swift)

by 伍雪颖


@IBAction func takePhoto(sender: AnyObject ) {
view . endEditing ( true )
@H_502_34@moveViewDown ()

let imagePickerActionSheet = UIAlertController (title: "Snap/Upload Photo" ,
message:
nil ,preferredStyle: . ActionSheet )

if UIImagePickerController . isSourceTypeAvailable (. Camera ) {
let cameraButton = UIAlertAction (title: "Take Photo" ,
style: .
Default ) { (alert) -> Void in
let imagePicker = UIImagePickerController ()
imagePicker.
delegate = self
imagePicker.
sourceType = . Camera
self . presentViewController (imagePicker,
animated:
true ,
completion:
nil )
}
imagePickerActionSheet.
addAction (cameraButton)
}

let libraryButton = "Choose Existing" ,129)">PhotoLibrary
addAction (libraryButton)

let cancelButton = "Cancel" ,129)">Cancel ) { (alert) -> in
}
imagePickerActionSheet.
addAction (cancelButton)

presentViewController (imagePickerActionSheet,animated: nil )
}

猜你在找的Swift相关文章