我想知道是否可以在按下 UiAlertController 中的按钮后推送到 newViewController
我的代码看起来像
@objc func handleAcceptRequest() {
let user = self.user
let username = user?.name
let alert = UIAlertController(title: "Are you Sure? ",message:" Would you like to accept \(username!) to complete your job?", preferredStyle: UIAlertController.Style.alert)
let cancelButton = UIAlertAction(title: "Cancel", style: .default, handler: {(_ action: UIAlertAction) -> Void in
print("you pressed cancel button")
})
let continueButton = UIAlertAction(title: "Continue", style: .default, handler: {(_ action: UIAlertAction) -> Void in
let vc = viewController()
let navController = UINavigationController(rootViewController: vc)
print("you pressed Continue")
})
continueButton.setValue(GREEN_Theme, forKey: "titleTextColor")
cancelButton.setValue(UIColor.red, forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(continueButton)
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
}
如果按下继续按钮,我只想展示 VC,但如果我打电话给礼物
// self.present(navController, 动画: true, 完成: nil)
在 continueButton 内部,我收到错误 Use of unresolved identifier 'present'
是否可以通过这种方式推送 newVC?