IOS:Warning: Attempt to dismiss from view controller <xxxxxxxxxController: 0x13f6840e0>

来源:互联网 发布:linux bg 参数 编辑:程序博客网 时间:2024/04/29 19:56
Ios:在你使用presentModalViewController加载过多的视图过程中,退出当前视图self dismissViewControllerAnimated:YES completion:nil];使用如果遇到报错,


2014-11-25 11:41:49.664xxxx[4745:60b] Warning: Attempt to dismiss from view controller <xxxxxViewController: 0x13f6840e0> while a presentation or dismiss is in progress!

如果使用

  if (![self.presentedViewController isBeingDismissed]) {

                    [self dismissViewControllerAnimated:YES completion:nil];

                               }

没有效果的情况下说明您的当前视图在主线程还没有加载出来,您可能需要使用如下代码

       dispatch_after(dispatch_time(DISPATCH_TIME_NOW,

                                         (int64_t)(0.51 *NSEC_PER_SEC)),

                           dispatch_get_main_queue(), ^{

                              if (![self.presentedViewControllerisBeingDismissed]) {

                                   [self dismissViewControllerAnimated:YES completion:nil];

                               }

 这样做的好处是让主线程等待0.5秒再退出视图, 就可以退出了!不信您试试!有效的请点赞!

0 0
原创粉丝点击