在演示或关闭正在进行时尝试从视图控制器中关闭 [英] Attempt to dismiss from view controller while a presentation or dismiss is in progress
问题描述
我有两个 UIViewController
类,其中在 FirstClass
我有一个 UIButton
用于 Login,当用户点击时在按钮上,我将显示 SecondClass
...为此,我已经完成了,
I have TWO UIViewController
classes, where in FirstClass
i have an UIButton
for Login, when user taps on button, i will display SecondClass
... For that i have done,
SecondClass *index = [[SecondClass alloc] init];
[self presentModalViewController:index animated:YES];
在SecondClass中,我有一个注销按钮,它将重定向到FirstClass,为此我已经完成了,
In SecondClass i have a logout button, which will redirect to FirstClass, for that i have done,
[self dismissModalViewControllerAnimated:YES];
当我在 SecondClass 中按下注销按钮时,我收到警告消息
When i press Logout button in SecondClass, i get the warning msg
**Attempt to dismiss from view controller <FirstClass: 0e39w88e160> while a presentation or dismiss is in progress!**
这里有什么问题..
推荐答案
添加了 iOS 6 和 iOS 6 之前的答案:
Added both iOS 6 and pre-iOS 6 answers:
iOS 5.0 及更高版本
当您退出时,在取消之前添加此检查:
When you logout, add this check before dismissing:
if (![self.presentedViewController isBeingDismissed])
{
[self dismissModalViewControllerAnimated:YES completion:nil];
}
iOS 4.X 及更低版本
在关闭之前添加此检查:
Add this check before dismissing:
if (![[self modalViewController] isBeingDismissed])
{
[self dismissModalViewControllerAnimated:YES];
}
这篇关于在演示或关闭正在进行时尝试从视图控制器中关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!