2011-06-23 32 views
1

私のアプリケーションデリゲートではperformSelecorInBackground:withObjectを使用してupdateDataメソッドを実行します。最後に、テーブルビューのオブザーバにデータをリロードするよう通知する通知がポストされます。メソッド呼び出しの直後に開始しないアニメーション

私の問題はアニメーションです:以下のコードを使用して、私のアニメーションはメソッドの最後に始まり、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); 

    }]; 

} 

答えて

4

セカンダリスレッドでUIKitを実行することはお勧めしません。変更する場合は、

[self performSelectorOnMainThread:@selector(updateUpAnimation) 
         withObject:nil 
        waitUntilDone:YES]; 
関連する問題