0
我有一個應用程序,可以讓用戶用相機拍照。我只想讓用戶拍攝風景照片,而不是肖像。有沒有辦法讓我鎖定相機的方向?橫向鎖定相機
下面是我使用的代碼:
func takePhoto() {
//If a camera is available on this device, go to camera. If not, present an error message.
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
//Create the image picker controller
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
//Present the camera view
presentViewController(imagePicker, animated: true, completion: nil)
}
else {
let alert = UIAlertController(title: "Error", message: "There is no camera available", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: {(alertAction) in alert.dismissViewControllerAnimated(true, completion: nil)}))
self.presentViewController(alert, animated: true, completion: nil)
}
}