简体   繁体   English

即使不满足标识符,Segue也会执行

[英]Segue performs even though identifier is not met

i've created a segue form a uibutton to a viewController with the style push. 我已经使用样式推送将一个uibutton从uibutton创建到viewController。 I only want this segue to be pushed if a criteria is met. 我只希望在符合条件的情况下推动此任务。 Therefor i've created an identifier like this: 为此,我创建了这样的标识符:

[self performSegueWithIdentifier:@"LoginSuccessful1" sender:self];

But it seems like that the segue is beeing pushed even though the performSegueWithIdentifier has not been called. 但是,即使尚未调用performSegueWithIdentifier,似乎segue仍在被推送。 How can i fix this? 我怎样才能解决这个问题?

Instead of having the segue go directly from the button, hook up the UIButton to an IBAction on your view controller. 与其直接从按钮中选择按钮,不如将UIButton挂接到视图控制器上的IBAction上。 Then, in this IBAction, check your condition and call your performSegue. 然后,在此IBAction中,检查条件并调用performPergue。 When hooking a segue directly from a button, the ViewController is not consulted first. 直接从按钮上挂接Segue时,不首先使用ViewController。

Remove the segue from button and connect it from ViewController to AnotherViewController as pushsegue not from UIButton 从按钮中删除segue ,然后将其从ViewController连接到AnotherViewController作为pushsegue而不是从UIButton

And check the condition and perform the segue 并检查条件并执行segue

if(this == that){

    [self performSegueWithIdentifier:@"LoginSuccessful1" sender:self];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么即使不满足换行条件,segue仍然执行? - Why is the segue executing even though the wrapping conditional is not met? Receiver没有带标识符的segue - 即使故事板中存在segue - Xcode 8,Swift 3 - Receiver has no segue with identifier - even though segue exists in storyboard - Xcode 8, Swift 3 接收者没有带有标识符的序列,尽管实际上已经声明了序列 - Receiver has no segue with identifier, though the segue is actually declared 即使陈述不正确,Swift Segue仍在运行 - Swift segue running even though if statment is not true segue无法识别segue标识符 - segue not recognizing segue identifier 通过按下注册按钮,即使所有文本字段都为空,segue 也会执行 - By pressing sign up button segue performs even if all text fields are empty 即使显示出Firebase登录中发生错误,我的Swift代码也会执行segue - My swift code performs a segue when even if it shows that an error is occuring in the firebase login 即使已触发segue,ViewController也不会显示 - ViewController not displaying even though segue has been triggered 即使我在情节提要中设置了segue,也从未调用prepareForSegue - prepareForSegue never got called even though I set the segue in storyboard 即使满足要求,可失败的初始化程序始终返回 nil - Failable initializer always returns nil even though requirements are met
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM