pushViewController Taking too much to show the view

后端 未结 2 1792
我寻月下人不归
我寻月下人不归 2021-01-20 06:03

I have a really light ViewController, it does nothing in viewDidLoad. I\'m pushing this view on top of a navigationController. The method who does this action is called from

相关标签:
2条回答
  • 2021-01-20 06:31

    From the docs for ABAddressBookRequestAccessWithCompletion:

    The completion handler is called on an arbitrary queue. If your app uses an address book throughout the app, you are responsible for ensuring that all usage of that address book is dispatched to a single queue to ensure correct thread-safe operation.

    You should make sure your UI code is called on the main thread.

    ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error {
         dispatch_async(dispatch_get_main_queue(), ^{
             [self showView];
             NSLog(@"EXECUTED");                
         });
    });
    
    0 讨论(0)
  • 2021-01-20 06:46

    This might not be the only problem, but according to the docs, the completion handler passed to ABAddressBookRequestAccessWithCompletion is called on an arbitrary queue. -showView should only be called on the main queue since it is dealing with UIViewController objects.

    The other thing to ask is what else is happening on the main queue? Are there other long-running tasks that could be blocking UI updates?

    0 讨论(0)
提交回复
热议问题