Swift 4无法解除并推送视图控制器

时间:2017-07-07 17:57:18

标签: ios swift

我正在使用Swift 4,我有以下代码:

let signInButton: UIButton = {
    let button = UIButton()
    button.setTitle("Sign In", for: .normal)
    button.setTitleColor(.white, for: .normal)
    button.translatesAutoresizingMaskIntoConstraints = false
    button.backgroundColor = UIColor(white: 0.4, alpha: 0.4)
    button.titleLabel!.font = .systemFont(ofSize: 20)
    button.addTarget(self, action: #selector(handlesignIn), for: .touchUpInside)
    return button
}()

@objc func handlesignIn() {
    dismiss(animated: true, completion: {
        print("a")
    })
    self.navigationController?.pushViewController(Main(), animated: true)
}

编写此代码的控制器为UIViewControllerMainUITabController。这段代码没有给我任何错误,但它也没有用。它甚至不打印"a"。那是为什么?

的AppDelegate:

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.makeKeyAndVisible()
    window?.rootViewController = SignIn()

0 个答案:

没有答案