[英]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.