单击按钮时,我正在使用performSegueWithIdentifier(),以便可以将正确的信息传递给下一个ViewController。当我单击按钮时,它将移至新视图空白视图,然后使用performSegueWithIdentifier()调用提供的信息打开所需的视图。这就要求用户单击两次“后退”按钮只是为了返回主视图。
有没有一种方法可以确保由于我使用performSegueWithIdentifier()而不会自动调用prepareForSegue()?我有这种感觉,因为我用performSegueWithIdentifier()调用了prepareForSegue(),然后第二次被自动调用。
这是我使用performSegueWithIdentifier()方法的代码:
if (page == 1)
[self performSegueWithIdentifier:@"time1" sender:self];
else if (page == 2
[self performSegueWithIdentifier:@"time2" sender:self];
else if (page == 3)
[self performSegueWithIdentifier:@"time3" sender:self];
else if (page == 4)
[self performSegueWithIdentifier:@"time4" sender:self];
else if (page == 5)
[self performSegueWithIdentifier:@"time5" sender:self];
else if (page == 6)
[self performSegueWithIdentifier:@"time6" sender:self];
else if (page == 7)
[self performSegueWithIdentifier:@"time7" sender:self];
else if (page == 8)
[self performSegueWithIdentifier:@"time8" sender:self];
else if (page == 9)
[self performSegueWithIdentifier:@"time9" sender:self];
else if (page == 10)
[self performSegueWithIdentifier:@"time10" sender:self];
else if (page == 11)
[self performSegueWithIdentifier:@"time11" sender:self];
else if (page == 12)
[self performSegueWithIdentifier:@"time12" sender:self];
else if (page == 13)
[self performSegueWithIdentifier:@"time13" sender:self];
这是我的prepareForSegue()方法:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"time1"] ||
[segue.identifier isEqualToString:@"time2"] ||
[segue.identifier isEqualToString:@"time3"] ||
[segue.identifier isEqualToString:@"time4"] ||
[segue.identifier isEqualToString:@"time5"] ||
[segue.identifier isEqualToString:@"time6"] ||
[segue.identifier isEqualToString:@"time7"] ||
[segue.identifier isEqualToString:@"time8"] ||
[segue.identifier isEqualToString:@"time9"] ||
[segue.identifier isEqualToString:@"time10"] ||
[segue.identifier isEqualToString:@"time11"] ||
[segue.identifier isEqualToString:@"time12"] ||
[segue.identifier isEqualToString:@"time13"])
{
InfoViewController *ivc = [segue destinationViewController];
if (_stringText != nil)
ivc.viewText = _stringText;
}//end if
}//end prepareForSegue
最佳答案
您正在采取什么动作?您执行performSegueWithIdentifier方法不应该调用自身,这绝对是为什么您要获得两个后退按钮的原因。您是否也将其连接到情节提要中?如果在情节提要中设置了脚本,则可能甚至根本不需要PerformSegueWithIdentifier调用,然后为每个脚本准备ForSegue。