【发布时间】:2019-05-18 18:44:57
【问题描述】:
我正在开发一个 iOS 应用程序,但我没有情节提要,并且我执行纯 swift 代码,当我尝试检查 MainViewController 中的身份验证并使用 perform 转到另一个 ViewController如果令牌不存在,则 MainViewController 中的显示按钮我遇到了这个警告,它将不起作用。
当我使用 perform(如下面的 sn-p)通过单击按钮转到另一个 ViewController 时,它工作得很好。
我已经看到了我在这里问的标题的所有答案,但是所有示例都有故事板,所以它与我在这里的问题无关。
这是我尝试在我的应用中执行的 sn-p。
if defaults.string(forKey: Constants().userTokenKey) != nil
&& defaults.string(forKey: Constants().userTokenKey) != "" {
print("YOU ARE IN ELSE!")
let vc = SelectLocationOnMapViewController()
UIApplication.topViewController()?.present(vc, animated: true, completion: nil)
} else {
UIView.animate(withDuration: 1, animations: {
self.loginRegisterParentView.alpha = 1.0
})
setButtonActions()
}
【问题讨论】: