从情节提要中删除 Segue。然后创建一个从文件所有者或所选视图底部的黄色小框到新的 modalViewController 的新文件。设置它的标识符并记住它。然后改变这个:
- (IBAction)calc:(id)sender {
int mynumber;
mynumber = [textfieldnumber.text intValue];
if (mynumber==0) {
NSString *errorstr = [[NSString alloc] initWithFormat:@"Please, set the number of people..."];
labelerror.text = errorstr;
}
}
对此:
- (IBAction)calc:(id)sender {
int mynumber;
mynumber = [textfieldnumber.text intValue];
if (mynumber==0) {
NSString *errorstr = [[NSString alloc] initWithFormat:@"Please, set the number of people..."];
labelerror.text = errorstr;
}else{
[self performSegueWithIdentifier:identifies sender:self];
}
}
或者
- (IBAction)calc:(id)sender {
int mynumber;
mynumber = [textfieldnumber.text intValue];
if (mynumber==0) {
NSString *errorstr = [[NSString alloc] initWithFormat:@"Please, set the number of people..."];
labelerror.text = errorstr;
}else{
[self presentModalViewController:viewController animated:YES];
}
}