Alertview操作快速导航到下一个View控制器后

时间:2018-07-21 07:55:17

标签: ios swift

我有两个Viewcontrollers, 当我单击“添加”按钮时,第一个ViewController中有一个AddButton,它导航到第二个ViewController,第二个ViewController中有验证按钮。在验证按钮内单击,在导航到我的第一个ViewController之后,我正在执行一些验证。导航到我的第一个ViewController并显示到警报ViewController后,它就可以工作,但是当我单击alerview操作时,它应该导航到第三个ViewController。我尝试了一次,但是当我单击alretview动作确定按钮时,它没有导航另一个ViewController
这是我的代码

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)
}

1 个答案:

答案 0 :(得分:0)

在Second View Controller中,

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)
    }
}