使用弹出视图(iOS,swift3)时以编程方式移动下一个视图

时间:2017-07-27 05:41:54

标签: ios swift3

当我想以编程方式移动UIVeiw时,我会使用此代码。

let customVC = UIStoryboard(name: "Main", bundle:nil).instantiateViewController(withIdentifier: "nextUIViewController") as! NextUIViewController
self.navigationController?.pushViewController(reservationsVC, animated: true)

我使用弹出窗口向用户提供信息。(我也使用tapView和导航控制器。)当我按下弹出窗口中的OK按钮时,我开始显示警报。我希望能够单击警报的“确定”按钮来移动视图。但在这种情况下,我的代码不起作用。

我想这不会是一个警报问题因为我之前使用过警报。任何人都知道这个问题或以编程方式移动UIView的不同方式吗?

这是我的整个代码(弹出窗口)

import UIKit
class ReservationPopupViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

}

@IBAction func closePopup(_ sender: UIButton) {
    dismiss(animated: true, completion: nil)
}

@IBAction func SelectTerm(_ sender: UIButton) {
}

@IBAction func selectNumberOfPeople(_ sender: UIButton) {
}

@IBAction func selectNumberOfChild(_ sender: UIButton) {
}



@IBAction func registReservation(_ sender: UIButton) {
    self.dismiss(animated: true, completion: nil)

    _ = SweetAlert().showAlert("Success", subTitle: "You did reservation", style: AlertStyle.success, buttonTitle:"OK") { (isOtherButton) -> Void in
        if isOtherButton == true {

            print("==== Clicked reservation ====")
            // move next page
            let reservationsVC = UIStoryboard(name: "Main", bundle:nil).instantiateViewController(withIdentifier: "reservationsController") as! ReservationsController

            self.navigationController?.pushViewController(reservationsVC, animated: true)

            print("==== Clicked reservation END====")

        }
    }

}

}

“====点击预订====”和“====点击预订END ====”输出成功。

0 个答案:

没有答案