gpt4 book ai didi

ios - Swift iOS 8 中的导航验证

转载 作者:行者123 更新时间:2023-11-29 02:09:06 25 4
gpt4 key购买 nike

This is a simple project which showing the navigation from one controller to another.

This picture shows that after I've pressed sign in without filling in the text field, it still redirects to next controller with alert message

我已经验证了如果两个文本字段都为空则用户无法登录。但是,警报消息会弹出,但它仍会导航到下一个 Controller 。如何克服这个问题?这存在于两个文本字段都是空白并且只显示警报消息,而不是导航到下一个 Controller 时?

最佳答案

我假设您有一个从“登录”按钮到下一个场景的转场。所以你要做的是实现

override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool 

然后检查标识符是否等于来自登录按钮的 segue 标识符。

我会将您的验证移动到此方法中,如果验证失败则返回 false,否则返回 true。

关于ios - Swift iOS 8 中的导航验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29478481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com