Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift-如何从ModalPopupController重新加载ViewController_Ios_Swift_Uiviewcontroller_Modalviewcontroller - Fatal编程技术网

Ios Swift-如何从ModalPopupController重新加载ViewController

Ios Swift-如何从ModalPopupController重新加载ViewController,ios,swift,uiviewcontroller,modalviewcontroller,Ios,Swift,Uiviewcontroller,Modalviewcontroller,我有两个ViewController,一个名为FirstViewController,它包含一个UIImage和一个UIButton,第二个名为ModalPopupViewController,它包含两个按钮 因此,在我的FirstViewController上,当我按下UI按钮时,它会在当前上下文上进行“交叉融合”转换 在ModalPopupViewController上,当我按下第一个按钮时,我使用UIImagePickerController选择一张图片并保存它,当我按下第二个按钮时,我关

我有两个ViewController,一个名为FirstViewController,它包含一个UIImage和一个UIButton,第二个名为ModalPopupViewController,它包含两个按钮

因此,在我的FirstViewController上,当我按下UI按钮时,它会在当前上下文上进行“交叉融合”转换
在ModalPopupViewController上,当我按下第一个按钮时,我使用UIImagePickerController选择一张图片并保存它,当我按下第二个按钮时,我关闭视图,但我的图片仅在重新启动应用程序时才显示。
当我离开ModalPopupViewController时,如何重新加载我的FirstViewController


我试图调用
viewwillbeen
viewdidebeen
,但当我从ModalPopupViewController返回FirstViewController时,没有附加任何内容

您可以使用委托模式

protocol ReloadManager {

    func reloadImageV(image:UIImage)
}
当你输入模态时

let modal = ///

modal.delegate = self

present(modal//////

class FirstVC:UIViewController , ReloadManager {


    func reloadImageV(image:UIImage) {
      // reload here
    }
}


class ModalVC:UIViewController {

    var delegate:ReloadManager?


    @IBAction func btnClicked(_ sender:UIButton) {

        delegate?.reloadImageV(image: sendedImage)

        dismiss(animated: true, completion: nil)
    }
}
//

移除segue并在导航到模态的btn操作中执行此操作,为模态提供一个故事板标识,将其转换为真实模态类名

let vc = self.storyboard?.instantiateViewController(withIdentifier: "modalID") as! ModViewController

vc.delegate = self

vc.providesPresentationContextTransitionStyle = true;

vc.definesPresentationContext = true;

vc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext

self.present(vc, animated: false, completion: nil)

我想我做错了什么,在我的
FirstViewController.swift
中,我在类外添加了协议,然后在类内添加了func和超类。在我的
ModalPopupViewController
中,我已经在我的按钮操作中添加了变量和函数。但是我的swift文件中没有这些行
let modal=///modal.delegate=self-present(modal///////code>如何呈现modal、、segue、present?我使用界面生成器制作了一个“呈现方式”转换你在哪里做自我表演