使用 UIIMagepickerController 打开相机不在 swift 上的 iPod Touch 上显示渲染视图
Opening camera using UIIMagepickerController not display rendering view on iPod Touch on swift
我正在使用 swift 开发客户端应用程序。这是我在 swift 上的第一个应用程序。我正在尝试使用 UIImagePickerController 从我的应用程序打开相机。下面我添加了我的代码快照。它在 IPhone 5s 和 6s 和 iOS 9.2.1 上运行良好。但是当我试图在 iPod Touch 上打开 iOS 8.3 时,它会显示带有按钮控件的黑色视图。我还附上了屏幕截图,其中显示了它的外观。请帮助我走出困境。
代码:
if UIImagePickerController.isSourceTypeAvailable(.Camera) {
imagePickerViewController = UIImagePickerController()
imagePickerViewController?.delegate = self
imagePickerViewController?.allowsEditing = true
imagePickerViewController?.sourceType = .Camera
imagePickerViewController?.mediaTypes = [kUTTypeImage as String]
imagePickerViewController?.cameraCaptureMode = .Photo
presentViewController(imagePickerViewController!, animated: true, completion: nil)
}
else
{
print("Sorry cant take picture")
}
我在我的设备上进行了相同的尝试,效果很好。所以代码没有问题。
现在我试图解决您在 iPod 上遇到的问题。请参阅以下步骤:
- 转到设置 > Select 您的应用程序
- 在那里你会看到带开关的照片和相机选项
- 如果我在相机中关闭那里,当我在那个应用程序中使用相机时它会开始显示黑屏
- 只需在您的 iPOD 设置中检查一下,如果它已关闭,请将其打开。它将开始工作。
希望这能为您提供指导。
我正在使用 swift 开发客户端应用程序。这是我在 swift 上的第一个应用程序。我正在尝试使用 UIImagePickerController 从我的应用程序打开相机。下面我添加了我的代码快照。它在 IPhone 5s 和 6s 和 iOS 9.2.1 上运行良好。但是当我试图在 iPod Touch 上打开 iOS 8.3 时,它会显示带有按钮控件的黑色视图。我还附上了屏幕截图,其中显示了它的外观。请帮助我走出困境。
代码:
if UIImagePickerController.isSourceTypeAvailable(.Camera) {
imagePickerViewController = UIImagePickerController()
imagePickerViewController?.delegate = self
imagePickerViewController?.allowsEditing = true
imagePickerViewController?.sourceType = .Camera
imagePickerViewController?.mediaTypes = [kUTTypeImage as String]
imagePickerViewController?.cameraCaptureMode = .Photo
presentViewController(imagePickerViewController!, animated: true, completion: nil)
}
else
{
print("Sorry cant take picture")
}
我在我的设备上进行了相同的尝试,效果很好。所以代码没有问题。
现在我试图解决您在 iPod 上遇到的问题。请参阅以下步骤:
- 转到设置 > Select 您的应用程序
- 在那里你会看到带开关的照片和相机选项
- 如果我在相机中关闭那里,当我在那个应用程序中使用相机时它会开始显示黑屏
- 只需在您的 iPOD 设置中检查一下,如果它已关闭,请将其打开。它将开始工作。
希望这能为您提供指导。