动画不是在方法调用后直接启动的

时间:2011-06-23 07:31:26

标签: iphone ios cocoa-touch core-animation

在我的应用代理中,我使用updateData执行performSelecorInBackground:withObject方法。最后,发布一条通知,告知我的tableview中的观察者重新加载数据。

我的问题在于动画:使用下面的代码,我的动画从方法结束开始,而不是直接在performSelector之后。

这是否与背景选择器有关或者还有其他我没有看到的东西?

非常感谢任何帮助。

谢谢!

- (void) updateData: (NSString *)newVersionNumber {


    ... CODE ...


    UIView *update = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 360, 20)];
    update.backgroundColor = [UIColor blackColor];
    [self.navController.view addSubview:update];

    [self performSelector:@selector(updateDownAnimation) withObject:nil];


    ... CODE ...


    [[NSNotificationCenter defaultCenter] postNotificationName:@"tableviewShouldReload" object:nil];


    ... CODE ...

    [self performSelector:@selector(updateUpAnimation) withObject:nil];

}

- (void) updateDownAnimation {


    [UIView animateWithDuration:0.3 animations:^{
        _window.frame = CGRectOffset(_window.frame, 0, 20);

    }];

}

1 个答案:

答案 0 :(得分:4)

不建议在辅助线程上执行UIKit。您可能希望将其更改为

[self performSelectorOnMainThread:@selector(updateUpAnimation)
                       withObject:nil
                    waitUntilDone:YES];
相关问题