2011-03-08 57 views
0

我開發一個應用程序中,我有當用戶在通訊錄中點擊它旋轉一個刪除按鈕如下如何再檢查一下按鈕

[UIView beginAnimations:nil context:nil]; 

    [UIView setAnimationDuration:.5]; 

    btn.transform=CGAffineTransformMakeRotation((0.0174532925)*90); 

    //put the -ve sign before 30 if you want to rotate the button in the anticlockwise else use this one 

    [UIView commitAnimations]; 
    selectedRow=btn.tag; 
    [self.tableView reloadData]; 

我要重新加載表時,動畫完成後如何轉我可以這樣做嗎?

回答

3
[UIView beginAnimations:@"rotateButton" context:nil]; 
[UIView setAnimationDuration:.5]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(myAnimDidStop:finished:context:)]; 
btn.transform = CGAffineTransformMakeRotation((0.0174532925)*90); 
[UIView commitAnimations]; 
selectedRow = btn.tag; 

的委託方法是這樣的:

- (void)myAnimDidStop:(NSString *)animID finished:(BOOL)finished context:(void*)ctx { 
    if ([@"rotateButton" isEqualToString:animID]) { 
     [self.tableView reloadData]; 
    } 
} 

請注意,如果您的目標的iOS 4和更新,你可以使用動畫塊:

[UIView animateWithDuration:0.5 
       animations:^{ 
        btn.transform = CGAffineTransformMakeRotation((0.0174532925)*90); 
        selectedRow = btn.tag; 
       } 
       completion:^(BOOL finished) { 
        [self.tableView reloadData]; 
       }]; 
相關問題