Xcode我想将变量传递给方法

时间:2012-09-17 16:28:28

标签: iphone objective-c xcode methods

-(void)end{
NSLog(@"End Called");

}    

UIImage *bPin = [UIImage imageNamed:@"BluePin.png"];
        UIImage *gPin = [UIImage imageNamed:@"GreenPin.png"];
        UIImage *rPin = [UIImage imageNamed:@"RedPin.png"];
        UIImage *yPin = [UIImage imageNamed:@"YellowPin.png"];
        UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,bPin.size.width,bPin.size.height)];
        image.animationImages = [NSArray arrayWithObjects:
                                 bPin,
                                 rPin,
                                 gPin,
                                 yPin,
                                 nil];

        image.animationRepeatCount = 0;
        image.animationDuration = 1.0;
        [image startAnimating];

        [image setFrame: CGRectMake(point.x-(image.bounds.size.width/2), point.y-(image.bounds.size.width/2), image.bounds.size.width, image.bounds.size.height)];
        [self.view addSubview: image];



        [UIView animateWithDuration:2.0 delay:1.0 options:UIViewAnimationOptionCurveLinear  animations:^{
            [image setAlpha:0.0];
        } completion:^(BOOL finished) {
            [image removeFromSuperview];

        }];

我想将图像发送到void end方法但是我该怎么做呢?我需要在那里结束它,以便为某个图像设置动画...我该如何发送它?????

2 个答案:

答案 0 :(得分:3)

我没看到问题是什么(也不是这个问题与Xcode有什么关系),为什么不简单

- (void)end:(UIImage *)img
{
    // do stuff
}

并将其称为

[self end:imageView.image];

答案 1 :(得分:0)

将您的结束方法更新为

- (void) end:(UIImageView *)imageToAnimate {
     NSLog(@"end called");
}

然后叫它:

[self end:image];