开发者

Error: Parameter name omitted

开发者 https://www.devze.com 2023-02-14 03:44 出处:网络
I\'m trying to have an auto reversing animation, and am getting the above error on the \"completion:^(BOOL)finished{\" line.

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

精彩评论

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