我有一個計時器來計算我的音頻時間。浮點比較和顯示消息
- (void)updateTime:(NSTimer *)timer
{
currentLocation = audio.currentTime;
[lblCurrentLocation setText:[NSString stringWithFormat:@"%.4f Sec",currentLocation]];
if (currentLocation == 4.7404)
{
[lblMsg setText:@"Sound p 1"];
}
}
這IF與4.7404比較CurrentLocation不工作: 當你得到一個時間我會在屏幕上放置一個標籤文本。有人有什麼主意嗎?
謝謝
也許currentTime的是4.7404000000000001而不是4.7404 ... – Macmade
嚴重的是,你有一個計時器,所以它的設置爲以一個(不準確)的時間間隔刷新......你如何期望獲得一個精確的時刻爲4.7404?!? – Macmade
我需要在我的聲音中顯示4.7404秒的精確時間,並在標籤中顯示消息。我怎樣才能做到這一點? – user722056