Dir*_*kLX 5 camera ios9 swift2
下面的代码显示了我访问图像lib的示例.无论我在哪里调用代码(视图),我都没有看到手机弹出的权限对话框,因此无法让我的应用程序访问相机或库.
此外,隐私设置也不显示我的应用程序.有什么想法吗?我疯了.
let imgPicker = UIImagePickerController()
imgPicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imgPicker.modalPresentationStyle = UIModalPresentationStyle.Popover
self.presentViewController(imgPicker, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我试过的另一种方式
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
let imagePicker:UIImagePickerController = self.imagePickerController
imagePicker.allowsEditing = true
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo
imagePicker.cameraDevice = UIImagePickerControllerCameraDevice.Rear
imagePicker.showsCameraControls = true
imagePicker.navigationBarHidden = true
imagePicker.toolbarHidden = true
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3864 次 |
| 最近记录: |