错误:省略参数名称

Joe*_*moe 4 iphone core-animation objective-c

我正在尝试使用自动倒车动画,并且在"完成:^(BOOL)完成{"行时出现上述错误.

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

                         }];
Run Code Online (Sandbox Code Playgroud)

注意我首先尝试使用以下代码,但按钮跳转到动画结束时的新位置.

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

Bol*_*ock 21

finishedBOOL参数的名称,Objective-C块具有C样式的函数签名,因此它必须在括号中.

该块的签名应该如下所示:

^(BOOL finished) {
}
Run Code Online (Sandbox Code Playgroud)