码迷,mamicode.com
首页 > 移动开发 > 详细

iOS.Performance-trick-presentViewController-is-so-slow-in-didSelectRowAtIndexPath

时间:2015-10-23 17:58:24      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

presentViewController is so slow in "tableView:didSelectRowAtIndexPath:"

 

Use Case: 在UITableView的delegate方法"tableView:didSelectRowAtIndexPath:"中调用

"[UIViewController presentViewController]"发现被显示的ViewController要有很长的延迟

才会显示出来。 

修改后:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSInteger rowInSection = indexPath.row;
    switch (rowInSection) {
        case 2: // age
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSDate * nowDate = [NSDate date];
                QZDatePickerViewController * datePickerViewController = [[QZDatePickerViewController alloc] initWithDate:nowDate];
                datePickerViewController.delegate = self;
                [self presentViewController:datePickerViewController
                                   animated:NO
                                 completion:nil];
            });

        }
            break;
   }

 

 


Reference 

1. presentViewController:animated:YES view will not appear until user taps again

http://stackoverflow.com/questions/21075540/presentviewcontrolleranimatedyes-view-will-not-appear-until-user-taps-again

iOS.Performance-trick-presentViewController-is-so-slow-in-didSelectRowAtIndexPath

标签:

原文地址:http://www.cnblogs.com/cwgk/p/4905032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!