我正在开发一个应用程序,当用户点击它时,我可以旋转删除按钮,如下所示
[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];
我想在动画完成后重新加载表格我该怎么办?
答案 0 :(得分: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];
}];