gpt4 book ai didi

iphone - ios 在条件下继续

转载 作者:可可西里 更新时间:2023-11-01 06:18:58 25 4
gpt4 key购买 nike

我正在尝试在某些情况下执行 segue。我在主 Storyboard 中创建了从 nextPushed 按钮到下一个 View Controller 的模态转场。

(IBAction)nextPushed:(id)sender {
//Perform check that every field /date/from/to/ choised and exists
NSString *fromText = [NSString alloc];
NSString *toText = [NSString alloc];
NSString *pasNumText = [NSString alloc];
NSString *dateText = [NSString alloc];
dateText = self.dateAndTimeLabel.text;
fromText = self.fromLabel.text;
toText = self.toLabel.text;
pasNumText = self.numOfPassengersLabel.text;
if (!([fromText isEqual:@"Choice" ]) && !([toText isEqual:@"Choice"] ) && !([pasNumText isEqual:@"Choice"]) && !([dateText isEqual:@"Choice"])) {
NSLog(@"All fields choisen");
NSLog(@"Going to next view");
[self performSegueWithIdentifier:@"goToDannie" sender:sender];
} else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Warning" message:@"Not all fields selected" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}

即使条件不为真,它也会执行 segue,并在下一个 View 中显示警报。

最佳答案

删除从按钮到 View Controller 的转场。相反,从包含 nextButton 的 View Controller 按住 control 并拖动到您要切换到的 View Controller 。然后performSegueWithIdentifier只有满足条件才会运行。

关于iphone - ios 在条件下继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18522232/

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