想要实现点击tableview中的一个cell,弹出一个页面,代码如下:
HSLoginViewController *loginVC = [HSLoginViewController new];
[self presentViewController:loginVC animated:YES completion:nil];
结果页面弹出速度非常慢,有时几秒钟才能弹出,又是根本不弹出,直到在页面上随意再次点击一下才弹出。
将代码做如下修改后,问题解决:
dispatch_async(dispatch_get_main_queue(), ^{
HSLoginViewController *loginVC = [HSLoginViewController new];
[self presentViewController:loginVC animated:YES completion:nil];
});
由此推断,presentViewController这个方法有可能不是在UI线程执行的。
本文介绍了一个iOS应用中TableView点击响应缓慢的问题,并通过调整代码执行路径解决了该问题。作者发现通过dispatch_async(dispatch_get_main_queue())确保了界面更新操作在主线程执行,从而提升了用户体验。

被折叠的 条评论
为什么被折叠?



