2011-02-26 67 views
2

我想要一個自動反轉動畫,並且正在「完成:^(BOOL)finished {」行上獲得上述錯誤。錯誤:省略參數名稱

  [UIView animateWithDuration:0.5 
           delay:0 
          options:UIViewAnimationOptionAutoreverse 
         animations:^{ 
          [[[self dieButtons] objectAtIndex:i] setTransform:CGAffineTransformMakeTranslation(0, 200)]; 
         } 
         completion:^(BOOL)finished{ 

         }]; 

注意我第一次嘗試使用下面的代碼,但按鈕跳到動畫結尾的新位置。

 [UIView beginAnimations:nil context:nil]; 
     [UIView setAnimationDuration:0.5]; 
     [UIView setAnimationRepeatAutoreverses:YES]; 
     [button setTransform:CGAffineTransformMakeTranslation(0, 200)]; 
     [UIView commitAnimations]; 

回答

16

finishedBOOL參數的名稱和Objective-C塊具有C風格的函數簽名,所以它必須是在括號中。

塊的簽名應該是這個樣子:

^(BOOL finished) { 
}