我有一些動畫會在加載根視圖控制器時自動啓動。這些動畫包含在viewDidLoad
中。當我導航到我的下一個視圖控制器並返回到根視圖控制器時,所有動畫都停止了。當我按「home」按鈕然後返回到視圖時,會發生相同的行爲。動畫在視圖控制器之間移動時不會重新啓動
我確定我在這裏錯過了一些非常基本的東西,但會很感激任何幫助。謝謝。
編輯1:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self beeBobbing];
//animate the butterfly oscillating
[self butterflyOscillate];
}
-(void) beeBobbing
{
[UIView animateWithDuration:1.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction) animations:^{
CGPoint bottomPoint = CGPointMake(215.0, 380.0);
imgBee.center = bottomPoint;
} completion:^(BOOL finished) {
}];
}
編輯2:這種類型的動畫似乎視圖之間切換時重新啓動:
-(void) animateClouds
{
[UIView animateWithDuration:30.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter;
} completion:^(BOOL finished) {
CGPoint rightScreenCenter = CGPointMake(1450.0, 119.0);
imgClouds.center = rightScreenCenter;
[UIView animateWithDuration:40.0f delay:0 options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionRepeat) animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter;
} completion:^(BOOL finished) {
}];
}];
}
你正在做什麼類型的動畫(動畫核心,UIView的animation.opengl等)以及什麼事件? –
道歉,我會更新OP – garethdn
你必須在viewDiDA中做同樣的動作,因爲itgets在切換views.call [self beeBobbing]; in viewDidAppear –