I'm pushing a UITableViewController
onto a UINavigationController
with pushViewController:animated:
. I'd like to be notified the moment the animation finishes so I can use selectRowAtIndexPath
to scroll to and highlight a given row.
How can I set the delegate of an animation I didn't call explicitly?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I know of no way to set the delegate of the push animation. Here's a simple workaround:
Subclass UITableViewController
. Override viewDidAppear:
to call your "post-animation" method after a short delay.
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self performSelector:@selector(scrollToAndHighlightCurrentRow) withObject:nil afterDelay:0.4];
}
回答2:
Have you tried simply calling the selectRowAtIndexPath:animated:scrollPosition: method (via the tableView property) before you push it onto the navigation controller's stack?