2016-02-29 64 views
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) 
    } 
} 

回答

1

有我鎖定相機方向

相機是一個物理對象的方式。它的方向與您的應用程序無關。 「鎖定相機方向」的唯一方法是伸出手並抓住用戶的手腕,以便他/她無法轉動設備。

相關問題