我正在尝试在某些情况下执行 segue。我在主 Storyboard 中创建了从 nextPushed 按钮到下一个视图控制器的模态序列。
(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。