iOS 关于presentViewController弹出页面反应迟钝的问题

来源:互联网 发布:知我药妆官方有假货吗 编辑:程序博客网 时间:2024/04/28 12:43

想要实现点击tableview中的一个cell,弹出一个页面,代码如下:


[objc] view plaincopy
  1. HSLoginViewController *loginVC = [HSLoginViewController new];  
  2. [self presentViewController:loginVC animated:YES completion:nil];        


结果页面弹出速度非常慢,有时几秒钟才能弹出,有时根本不弹出,直到在页面上随意再次点击一下才弹出。

将代码做如下修改后,问题解决:


[objc] view plaincopy在CODE上查看代码片派生到我的代码片
  1. dispatch_async(dispatch_get_main_queue(), ^{  
  2.             HSLoginViewController *loginVC = [HSLoginViewController new];  
  3.             [self presentViewController:loginVC animated:YES completion:nil];  
  4.         });  


由此推断,presentViewController这个方法有可能不是在UI线程执行的。


0 0
原创粉丝点击