2011-09-14 111 views
1

Apple Documentation設置repeatCount到1e100f給予警告

Setting the repeatCount to 1e100f will cause the animation to repeat until it is removed from the layer. 

這裏是我的代碼:

CABasicAnimation *flicker = [CABasicAnimation animationWithKeyPath:@"opacity"]; 
flicker.repeatCount = 1e100f; 

Xcode中給出了一個警告:

Semantic Issue: Magnitude of floating-point constant too large for type 'float'; maximum is 1.7014116E+38 

什麼我做錯了嗎?

+0

Googol文檔看起來不太合適。提交一份錯誤報告,看看蘋果是否知道無限循環的正確方法。 –

回答

10

嘗試使用HUGE_VALF(我認爲是1e50f,但使用常量)。查找repeatCount告訴我們:

將此屬性設置爲HUGE_VALF將導致動畫永久重複。

+2

似乎工作,雖然我不會坐在我的椅子上等待。 – ninjaneer

1

change flicker.repeatCount = 1e100f; 至 flicker.repeatCount = 1e100;

+0

這個改變是什麼? – Ren

+0

擺脫了你的警告,它應該是一個浮點值 – Bhushan