在为 iOS 制作应用程序时,我仍然是一个菜鸟,我不明白为什么我会遇到某个错误。对于我当前的项目,我正在尝试切换 View ,但我无法让它工作,我也不明白为什么。我遵循了按钮( http://www.youtube.com/watch?v=ph3XhJD8QAI )的教程,尽管教程较旧,但它仍然有效。我不得不编辑一些代码以确保它适用于 Xcode 5。每次我按下按钮切换 View 时,我都会收到一条错误消息,内容为“警告:尝试在
这是我的切换 View 按钮的代码
-(IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
最佳答案
在呈现另一个 View 之前,您必须完全忽略一个 View 。尝试:
[self dismissViewControllerAnimated:YES completion: ^{
SecondView *second =
[[SecondView alloc] initWithStyle:UITableViewStylePlain];
controller.modalTransitionStyle = UITableViewStylePlain;
[self presentViewController:second animated:YES completion:nil];
}];
关于ios - Xcode5错误: Warning attempt to present <View> on <OtherView> while presentation is in progress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19571780/