想要實現點擊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線程執行的。