每次在UIImagePickerController()的dismiss()之后调用viewDidLoad(). [英] viewDidLoad() is called every time after dismiss() of UIImagePickerController()

查看:45
本文介绍了每次在UIImagePickerController()的dismiss()之后调用viewDidLoad().的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 ViewControllerA 中提出了 UIImagePickerController(),当我选择一个图像时,它的委托被调用,在该委托中我写了

I presented UIImagePickerController() from ViewControllerA and when I select a image its delegate called and in that delegate I wrote

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

        dismiss(animated: true, completion: nil)
}

ViewControllerA viewDidLoad()也称为

推荐答案

请找到以下代码,不会每次都调用viewDidLoad.

Please find below code, viewDidLoad doesn't get called every time.

override func viewDidLoad() {
    super.viewDidLoad()
    print("View Did Load")
}

private func imagePickerController(_ picker: UIImagePickerController,
                           didFinishPickingMediaWithInfo info: [String : AnyObject]) {
    picker.dismiss(animated: true, completion: nil);

    _ = info[UIImagePickerControllerOriginalImage] as! UIImage
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
    picker.dismiss(animated: true, completion: nil)
}

使用此代码打开照片库,

Open Photo Library using this code,

@IBAction func btnclicked(_ sender: Any) {
    let picker = UIImagePickerController()
    picker.sourceType = .photoLibrary
    picker.delegate = self
    self.present(picker, animated: true, completion: nil)
}

还要发布您的一些代码,以便我进行审核.

Also post some of your code so I can review it.

如有任何疑问,请通知我.

Let me know in case of any queries.

这篇关于每次在UIImagePickerController()的dismiss()之后调用viewDidLoad().的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆