廢話不說,先上代碼:
1 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 2 { 3 switch (buttonIndex) { 4 case 0:{ 5 // 進入搜尋網頁面查詢適合崗位。 6 [self.navigationController popToRootViewControllerAnimated:NO]; 7 AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; 8 UITabBarController *tabbarController = [appDelegate tabbarController]; 9 [tabbarController setSelectedIndex:1];10 }11 break;12 case 1:{13 [self.navigationController popToRootViewControllerAnimated:YES];14 }15 break;16 default:17 break;18 }19 }
過程是這樣的:在彈出的alter中點擊按鈕(index==0)會先將目前的navController pop 到根視圖控制器,然後通過tabbarController切換到另外一個選項卡中。結果就遇到了wait_fences: failed to receive reply: 10004003 的警告,雖然程式不會crash,但是會有明顯的延遲。
如果只是navController的pop方法,無論 Animated 是否開啟都是沒有問題的,只是加上tabbarController的選項卡切換後就會出現wait_fences: failed to receive reply: 10004003 的警告。
經過網上問題的搜尋,初步判斷可能是因為在運行 clickedButtonAtIndex 方法時,alterview還沒有完成dismiss動畫過程(或者還根本沒有開始),這時進行頁面切換導致上面的問題,於是換用 didDismissWithButtonIndex 方法發現問題解決了(不過是在alterview dismiss動畫完成之後頁面才切換的)。
雖然問題解決了,但是還是不太清楚究竟根源錯在哪裡。。。等待大神指教。