I have an app with long data list in the tableView, and I would like to double tap the navigationBar to scroll the UITableView on top of the list (where the search is).
How can I implement that?
Thanks for your help.
I have an app with long data list in the tableView, and I would like to double tap the navigationBar to scroll the UITableView on top of the list (where the search is).
How can I implement that?
Thanks for your help.
The standard gesture for scrolling a tableView to the top is a double tap on the status bar. It's enabled by default see UIScrollView Reference
If you really want the navigation bar and you're targeting 3.2 and up I would recommend to attach an UITapGestureRecognizer to the navigationBar.
- (void)viewDidLoad {
UITapGestureRecognizer* tapRecon = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(navigationBarDoubleTap:)];
tapRecon.numberOfTapsRequired = 2;
[navController.navigationBar addGestureRecognizer:tapRecon];
[tapRecon release];
}
- (void)navigationBarDoubleTap:(UIGestureRecognizer*)recognizer {
[tableView setContentOffset:CGPointMake(0,0) animated:YES];
}
If you're targeting 3.0 or below it could become a little tricky and is not recommend.