出于某种奇怪的原因,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"];
}