【发布时间】:2014-06-30 02:02:25
【问题描述】:
有一个非常奇怪的问题。我有一个通过 NSTimer 随机移动的 UIImageView。运动运行相当顺利,没有任何问题,但由于某种原因,当视图加载动画时,动画将开始,然后重置并重新开始,使其看起来滞后且不专业。知道可能是什么原因造成的吗?我之前遇到过这个问题,并且更改时间间隔然后将其更改回来似乎可以解决它,但这现在不起作用。非常感谢任何帮助,因为这真的让我很沮丧。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
fScale = CGPointMake(.99, 1.01);
df = CGPointMake(1,.5);
fTimer = [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(fMove) userInfo:nil repeats:YES];
}
-(void)fMove
{
form.center = CGPointMake(form.center.x +df.x, form.center.y + df.y);
if (df.x <.15 && df.x > -.15)
{
df.x *= -1/df.x;
fScale.x = .99;
if(df.y > 0)
df.y = .5;
else
df.y = -.5;
fScale.y = 1.01;
}
if (df.x < .5 && df.x > -.5)
{
fScale.x *= .995;
fScale.y *= .995;
}
if (form.center.x < 100 || form.center.x >220)
df.x *= -1;
if (form.center.y <10 || form.center.y >530)
df.y *= -1;
df.x *= fScale.x;
df.y *= fScale.y;
}
【问题讨论】:
标签: ios objective-c xcode animation uiimageview