gpt4 book ai didi

ios - UIImagePickerControllerDelegate 到 Swift?

转载 作者:可可西里 更新时间:2023-11-01 00:24:37 24 4
gpt4 key购买 nike

    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)
{

var imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera;
//imagePicker.mediaTypes = kUTTypeImage
imagePicker.allowsEditing = false

self.presentViewController(imagePicker, animated: true, completion: nil)

}

我似乎无法将 kUTTypeImage 转换为 swift,如果我注释掉这一行,相机会启动,但屏幕是黑色的。有任何想法吗?这是 Objective-C 语法:

imagePicker.mediaTypes = @[(NSString *) kUTTypeImage];

最佳答案

显然是这么简单:

if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)
{
var imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.Camera;
imagePicker.mediaTypes = [kUTTypeImage]
imagePicker.allowsEditing = false

self.presentViewController(imagePicker, animated: true, completion: nil)
}

关于ios - UIImagePickerControllerDelegate 到 Swift?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24006807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com