2011-10-25 29 views
1

我有一個正在顯示自定義UIViewController的UIPopoverViewController。當我點擊一個按鈕,我有一個動作運行,因此我添加一個視圖到UIViewController的視圖的視圖層次結構。UIPopoverViewController添加子視圖很慢

問題是,它非常慢,需要幾秒鐘的時間才能顯示視圖。我沒有用我的UIViewController的代碼做任何不尋常的事情。

- (void)showAccountChooser { 
    self.twitterAccountPicker = [TwitterAccountPicker new]; 
    [self.view addSubview:self.twitterAccountPicker.view]; 
    self.twitterAccountPicker.view.frame = self.view.bounds; 

    self.twitterAccountPicker.view.transform = CGAffineTransformMakeScale(.05, .05); 

    [UIView animateWithDuration:0.5f animations:^{ 
     self.twitterAccountPicker.view.transform = CGAffineTransformMakeScale(1, 1); 
    } completion:^(BOOL finished) { 
     //[self.twitterAccountPicker viewDidAppear:YES]; 
    }]; 
} 

是我添加的UIViewController中是微不足道的,並在viewDidLoad中或viewWill/DidAppear不重處理。我已經設置了斷點並確認它沒有做任何事情不好

添加視圖時,其他人注意到這一點?

回答

1

設置了試圖調試這個斷點之後,我意識到我的showAccountChooser方法是從塊調用中調用的,這是發生在後臺線程上的。將此調用移至主線程可解決問題。