我有一個在我的代碼中運行的檢查。如果檢查返回true,我執行一個動畫並向用戶顯示一個UIAlertView。我的問題是,我不知道如何延遲UIAlertView直到動畫完成。所以,目前顯示的是UIAlertView,並且動畫在後臺運行。我會很感激任何幫助。下面是相關代碼:在UIAlertView上設置延遲
BOOL isComplete = [self checkJigsawCompleted:droppedInPlace withTag:tag];
if (isComplete) {
[stopWatchTimer invalidate];
stopWatchTimer = nil;
[self updateTimer];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
imgGrid.alpha = 0;
imgBackground.alpha = 0;
[UIView commitAnimations];
NSString *completedMessage = [NSString stringWithFormat:@"You completed the puzzle in: %@", lblStopwatch.text];
UIAlertView *jigsawCompleteAlert = [[UIAlertView alloc] //show alert box with option to play or exit
initWithTitle: @"Congratulations!"
message:completedMessage
delegate:self
cancelButtonTitle:@"I'm done"
otherButtonTitles:@"Play again",nil];
[jigsawCompleteAlert show];
}
就這麼簡單!謝謝。你能告訴我1.0f中「f」的意義嗎? – garethdn
「f」表示它是一個浮點數。 –
「它」是指秒數?這是必要的還是僅僅是良好的做法?我見過幾個沒有'f'的例子。 – garethdn