2015-04-04 2 views
0

У меня есть анимация, которая в настоящее время работает. Я последовал за этим ответом Xcode How to move an image up and down animationКак запустить анимацию после определенного сеанса?

Я получил анимацию, нажатую кнопкой. Я действительно хочу, чтобы вызвать анимацию после определенного сеанса. Можно ли запускать эту анимацию, когда я перехожу к определенному виду в своем раскадровке?

Анимация в методе внутри моей реализации ViewController.

-(void)animatePicker 
{ 

    NSLog(@"Animate"); 
    CGPoint startPoint = (CGPoint){100.f, 100.f}; 
    CGPoint middlePoint = (CGPoint){400.f, 400.f}; 
    CGPoint endPoint = (CGPoint){600.f, 100.f}; 

    CGMutablePathRef thePath = CGPathCreateMutable(); 
    CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y); 
    CGPathAddLineToPoint(thePath, NULL, middlePoint.x, middlePoint.y); 
    CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y); 

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
    animation.duration = 3.f; 
    animation.path = thePath; 
    [pickerCircle.layer addAnimation:animation forKey:@"position"]; 
    pickerCircle.layer.position = endPoint; 
} 

ответ

2

Внедрение a - (void) viewDidAppear; в вашем UIViewController и вызовите функцию анимации.

Эта функция вызывается, когда представление UIViewController было создано и появилось также.

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
    NSLog(@"viewDidAppear"); 
    [masterViewController animate]; 
} 
Смежные вопросы