我有一个应用程序,让用户可以用相机拍照。我想只允许用户拍摄风景照片,而不是肖像。我有办法锁定相机方向吗?
以下是我正在使用的代码:
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)
}
}
答案 0 :(得分:0)
我有办法锁定相机方向吗
相机是物理对象。它的方向与您的应用程序无关。 “锁定相机方向”的唯一方法是伸出并抓住用户的手腕,这样他/她就无法转动设备。