0

我有一個UIActivityIndicator這是工作以及在iPhone 3G模擬器/設備良好,但它不適用於iPhone 4(視網膜)的模擬器/設備。我想提到它是在黑色的背景上。UIActivity指標不適用於iPhone 4(視網膜)

+2

請說明'not working'的含義。它顯示不正確,沒有顯示在屏幕上等。屏幕截圖會很好。 – 2011-01-28 08:48:44

+0

它沒有顯示。 – 2011-01-28 09:12:41

回答

5

我以前有過類似的問題。這是通過改變指標風格到UIActivityIndicatorViewStyleWhiteLarge並給出一個對比的顏色(我選擇黑色)到背景來解決的。問題實際上是它不可見。

+0

其實風格設置爲UIActivityIndi​​catorViewStyleWhiteLarge,背景也是黑色的。 – 2011-01-28 12:39:56

2

UIActivityIndi​​cator不會立即顯示。

如果你有如下代碼:

//(pseudo-code) 
//Create UIActivityIndicator 
//show UIActivityIndicator 
//do some other stuff expecting view to show 

的UIActivityIndi​​cator不會出現,因爲UIActivityIndi​​cator將只在程序的下一個運行循環顯示。

您可以通過

{ 
    //create UIActivityIndicator 
    //show UIActivityIndicator 
    [self performSelector:@selector(doOtherStuff) withObject:nil afterDelay:0]; 
} 

-(void)doOtherStuff { 
    //do stuff 
} 

解決這個問題的performSelector意味着,doOtherStuff對下一個運行循環,當UIActivityIndi​​cator會顯示完成。

您還必須將其作爲子視圖添加到您希望顯示的視圖中。

0

也許你是從一個不是主線程的線程顯示微調框?你可以試試這個斷言找出無論你在主線程:

NSAssert([[NSThread currentThread] isMainThread], 
    @"This should be run from the main thread."); 

如果斷言失敗,您可以調度調用主線程:

dispatch_async(dispatch_get_main_queue(), ^{ 
    // display the spinner 
}); 

無論如何,沒有看到我們都只是猜測的代碼。