首页 > 解决方案 > Alertview 操作 快速导航到下一个视图控制器后

问题描述

我有两个,当我单击添加按钮时Viewcontrollers,第一个有一个 AddButton,它导航到第二个,第二个有验证按钮。在验证按钮内单击我正在执行一些验证,然后它导航到我的第一个。一旦它导航我第一次显示它正在工作的警报,但是当我单击 alerview 操作时,它应该导航到第三个。我试过了,但是当我单击 alretview Action OK 按钮时,它没有导航另一个。 这是我的代码ViewControllerViewControllerViewControllerViewControllerViewControllerViewControllerViewControllerViewController

Firstviewcontroller button in side

let lv = NAViewPresenter().otpViewController()
self.navigationController?.pushViewController(lv, animated: true)

In SecondView Controller inside Button,

self.navigationController?.popViewController(animated: true)
OpacityView.shared.showingPopupView(view: self)
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.stopTimer), userInfo: nil, repeats: true)

@objc func stopTimer() {
            OpacityView.shared.hidingPopupView()
            if (count >= 0){
                if(count == 0)
                {
                    self.addAlertViewAction()
                }
                count -= 1
            }
        }

func addAlertViewAction() {
           let alertController = UIAlertController(title:NAString().add_my_service(), message:NAString().addButtonloadViewMessage(), preferredStyle: .alert)
            // Create OK button
            let OKAction = UIAlertAction(title: "OK", style: .default) { (action:UIAlertAction!) in
                let lv = NAViewPresenter().myDailyServicesVC()
                lv.fromAddMyDailyServicesVC = true
//                self.present(lv, animated: true, completion: nil)
               self.navigationController?.pushViewController(lv, animated: true)
            }
            alertController.addAction(OKAction)
self.present(alert, animated: true, completion: nil)
}

标签: iosswift

解决方案


在第二视图控制器中,

import UIKit

protocol CustomDelegate {

    func sendValues(withData : Any)
}

class SecondViewController: UIViewController {

    var popupView: PopupView!


    var delegate : CustomDelegate?

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    @IBAction func popButtonAction() {
        self.navigationController?.popViewController(animated: true)
        delegate?.sendValues(withData: (Any).self)
    }
}

推荐阅读