我试图在swift中使用UIImagePickerController,但不工作…
@H_404_16@
您还应该在控制器中导入MobileCoreServices:
我的ViewController:
class ViewController: UIViewController { @IBOutlet var imag : UIView = nil @IBAction func capture(sender : UIButton) { println("Button capture") if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) { var imag = UIImagePickerController() imag.delegate = self imag.sourceType = UIImagePickerControllerSourceType.Camera; imag.mediaTypes = kUTTypeImage imag.allowsEditing = false self.presentViewController(imag,animated: true,completion: nil) } } }
imag.delegate = self (Type'ViewControlles does confoorm to protocol 'UIImagePickerControllerDelegate') imagePicker.mediaTypes = kUTTypeImage (use of unresolved identifier kUTTypeImage)
我已经阅读kUTTypeImage不能使用在swift.but不知道,我使用坏的这个功能。任何帮助?
谢谢!!
import MobileCoreServices
然后将类型放在方括号中,如下所示:
imag.mediaTypes = [kUTTypeImage]