1

performSelector:withObject:afterDelay:持続時間のあるアニメーションを実行する by というメソッドがあります。したがって、遅延の後、アニメーションは実行されますが、アニメーションの長さはありません。

[self performSelector:@selector(animate:) withObject:[NSNumber numberWithInt:-1] afterDelay:4.0];

-(void) animate:(int) mode
{
[UIView animateWithDuration:0.2
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     self.center = CGPointMake(160.0, 568.0 + mode*height/2);
                 }
                 completion:nil];
}

completion:また、 UI インタラクションをブロックするため、アニメーションをネストできません。

4

2 に答える 2

0

私はあなたのコードを試してみましたが、アニメーションの長さはうまく機能しますが、(int) モードの部分を修正する必要があると思います。そのように NSNumber を int にキャストすることはできません。メソッドは - (void)animate:(NSNumber*)mode である必要があり、[mode intValue] で int にキャストできるようになった後です。

于 2013-11-18T08:26:30.290 に答える
0

オブジェクトポインタ型ではないパラメータをperformSelector:withObject:afterDelay:持つため、 withは使用できません。animate:

于 2013-11-19T22:43:17.980 に答える