开发者

Error: Parameter name omitted

I'm trying to have an auto reversing animation, and am getting the above error on the "completion:^(BOOL)finished{" line.

      开发者_运维问答      [UIView animateWithDuration:0.5 
                              delay:0
                            options:UIViewAnimationOptionAutoreverse
                         animations:^{
                             [[[self dieButtons] objectAtIndex:i] setTransform:CGAffineTransformMakeTranslation(0, 200)];
                         }
                         completion:^(BOOL)finished{

                         }];

Note I first attempted this with the following code but the button jumped to the new location at the end of the animation.

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


finished is the name of the BOOL parameter, and Objective-C blocks have C-style function signatures, so it has to be in the parentheses.

The block's signature is supposed to look like this:

^(BOOL finished) {
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜