Xcode:UIImageView位置(使用NSTimer移动)在不同的UIImage图像更改后重置

时间:2015-06-28 20:35:18

标签: objective-c uiimageview xcode6 nstimer reset

出于某种奇怪的原因,UIImageView向下移动NSTimer似乎会重置并在每次点击更改不同IBAction图片的UIImageView时继续移动。

以下是代码:

在我的.h

@interface Game : UIViewController{
    IBOutlet UIImageView *image1;


    NSTimer *myTimer;

}

@property (weak, nonatomic) IBOutlet UIImageView *differentImage1;

在我的.m

 -(IBAction)start{

        myTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(Movement) userInfo:nil repeats:YES];

    }
    -(void)Movement{

        image1.center = CGPointMake(image1.center.x, image1.center.y + 7);

    }

    -(IBAction)changeDifferentImage{

        _different1.image = [UIImage imageNamed:@"blue.png"];

    }

    -(IBAction)changeDifferentImage2{

        _different1.image = [UIImage imageNamed:@"green.png"];

    }

0 个答案:

没有答案