ios - Xcode5错误: Warning attempt to present <View> on <OtherView> while presentation is in progress

标签 ios iphone objective-c xcode xcode5

在为 iOS 制作应用程序时,我仍然是一个菜鸟,我不明白为什么我会遇到某个错误。对于我当前的项目,我正在尝试切换 View ,但我无法让它工作,我也不明白为什么。我遵循了按钮( http://www.youtube.com/watch?v=ph3XhJD8QAI )的教程,尽管教程较旧,但它仍然有效。我不得不编辑一些代码以确保它适用于 Xcode 5。每次我按下按钮切换 View 时,我都会收到一条错误消息,内容为“警告:尝试在 上呈现 ,而演示正在进行中!” 和iPhone 模拟器中的屏幕变黑了。我也在使用 Storyboard,我不确定这是否与情况有关。谁能告诉我我做错了什么?如果我需要添加更多代码以进行说明,请告诉我!在此先感谢您的帮助

这是我的切换 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/

相关文章:

ios - 重新加载 FSCalendar View

ios - UISearchBar 到 UISearchDisplayController 的转换关闭了 20px

iphone - 在设备上录制时收到 ConvertInput 使用无效 anchor 时间错误

iphone - 仅将变量用于单元测试

ios - 粘贴到 UISearchController 的 UISearchBar 时启用返回键

iphone - 收到内存警告。等级=1

ios - 单击多个单元格上的 UItableview 正在快速检查 3

java - "users"的 Realm IO应用

iphone - 如何为 NSString drawAtPoint 设置上下文?

objective-c - Cocoa Visual Format Language 中的 View 名称是什么?