Delay in presenting a modal view controller

前端 未结 9 1819
星月不相逢
星月不相逢 2020-12-24 10:51

I have a tab bar based app. There are navigation controllers in all 5 tabs with instances of custom view controller setup properly as root view controllers. This loads just

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 11:29

    It seems calling presentViewController:animated:completion from within tableView:didSelectRowAtIndexPath: is problematic. It's difficult to find anything that stands out when using the Time Profiler in Instruments, also. Sometimes my modal view comes up in less than a second and other times it takes 4s or even 9s.

    I think it's related to the underlying UIPresentationController and layout, which is one of the few things I see when selecting the region of time between tapping on a row and seeing the modal presentation in the Time Profiler.

    A Radar exists describing this issue: http://openradar.appspot.com/19563577

    The workaround is simple but unsatisfying: delay the presentation slightly to avoid whatever contentious behavior is causing the slowdown.

    dispatch_async(dispatch_get_main_queue(), ^{
       [self presentViewController:nav animated:YES completion:nil];
    });
    

提交回复
热议问题