pushViewController太多的显示视图 [英] pushViewController Taking too much to show the view

查看:143
本文介绍了pushViewController太多的显示视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常轻的ViewController,它不会在viewDidLoad。我把这个视图顶部的navigationController。执行此操作的方法从块内部调用。调用showView后,我添加了一个NSLog,并且该日志打印在控制台真的很快,但视图需要很多加载...我真的不明白什么可能发生...任何想法???

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 inside a block. After the call to showView I added an NSLog, and that log prints in the console really fast, but the view takes a lot to load... I really don't understand what maybe happening... any idea???

ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
    [self showView];
    NSLog(@"EXECUTED");                
});

- (void) showView{
    TestViewController *test = [[TestViewController alloc]init];
    [self.navigationController pushViewController:test animated:NO];
}


推荐答案

c $ c> ABAddressBookRequestAccessWithCompletion :

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.

您应该确保在主线程上调用您的UI代码。

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");                
     });
});

这篇关于pushViewController太多的显示视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆