【问题标题】:Animations not starting directly after method call方法调用后动画不直接启动
【发布时间】:2011-06-23 07:31:25
【问题描述】:

在我的应用委托中,我使用performSelecorInBackground:withObject 执行我的updateData 方法。最后,会发布一条通知,告诉我的 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);

    }];

}

【问题讨论】:

    标签: iphone ios cocoa-touch core-animation


    【解决方案1】:

    不建议在辅助线程上做 UIKit 的事情。您可能希望将其更改为

    [self performSelectorOnMainThread:@selector(updateUpAnimation)
                           withObject:nil
                        waitUntilDone:YES];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多