首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无滞后性的动画?

无滞后性的动画?
EN

Stack Overflow用户
提问于 2013-04-28 22:34:33
回答 1查看 71关注 0票数 0

我目前正在使用以下代码来动画视图之间的转换,当调用refreshTheServers方法时,整个应用程序会冻结、刷新服务器,然后显示视图。

我如何使这个过程成为一个无缝的过程,在这个过程中视图会被刷新,然后服务器就会被刷新?

代码语言:javascript
运行
复制
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[self.view addSubview:self.folderView];
[UIView commitAnimations];
[self refreshTheServers];

编辑:下面是refreshTheServers方法的代码:

代码语言:javascript
运行
复制
- (void)refreshTheServers {

KeychainItemWrapper* keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"KeychainTest" accessGroup:nil];

NSString *userForConnect = [NSString stringWithFormat:@"%@", [keychain objectForKey:(__bridge id)(kSecAttrAccount)]];
NSString *passForConnect = [NSString stringWithFormat:@"%@", [keychain objectForKey:(__bridge id)(kSecValueData)]];



CTCoreAccount *account = [[CTCoreAccount alloc] init];

dispatch_queue_t taskQ = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_async(taskQ, ^{
    [account connectToServer:[[NSUserDefaults standardUserDefaults]
                              stringForKey:@"server"]
                        port:993
              connectionType:CTConnectionTypeTLS
                    authType:CTImapAuthTypePlain
                       login:userForConnect
                    password:passForConnect];

    dispatch_async(dispatch_get_main_queue(), ^{
        // ... the thread is over, do stuff on the main thread ...

        CTCoreFolder *inbox = [account folderWithPath:theAppDelegate.folder];

        NSArray *inboxMessages = [inbox messagesFromUID:1 to:0 withFetchAttributes:CTFetchAttrEnvelope];

        [[self allMessages] removeAllObjects];
        [[self allMessages] addObjectsFromArray:inboxMessages];

        [self.messagesTable reloadData];
    });
});
}

我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-28 23:15:58

下面的调用是同步的:收件箱消息freezes :1到:0 withFetchAttributes:CTFetchAttrEnvelope;这就是应用程序冻结的原因。仪器CPU取样器可以突出显示这一点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16268748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档