我有两个 UIViewController
类,在 FirstClass
中我有一个 UIButton
用于 Login,当用户点击在按钮上,我将显示 SecondClass
... 为此,我已经完成了,
SecondClass *index = [[SecondClass alloc] init];
[self presentModalViewController:index animated:YES];
在 SecondClass 中我有一个logout 按钮,它将重定向到 FirstClass,因为我已经这样做了,
[self dismissModalViewControllerAnimated:YES];
当我在 SecondClass 中按下注销按钮时,我收到警告消息
**Attempt to dismiss from view controller <FirstClass: 0e39w88e160> while a presentation or dismiss is in progress!**
这里有什么问题..
最佳答案
添加了 iOS 6 和 iOS 6 之前的答案:
iOS 5.0 及更高版本
注销时,在关闭之前添加此检查:
if (![self.presentedViewController isBeingDismissed])
{
[self dismissModalViewControllerAnimated:YES completion:nil];
}
iOS 4.X 及更低版本
在解散之前添加此检查:
if (![[self modalViewController] isBeingDismissed])
{
[self dismissModalViewControllerAnimated:YES];
}
关于iphone - 在演示或解散过程中尝试从 View Controller 中解散,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15875538/