slightly different scrolling needed after searching
-
19-09-2019 - |
Question
I have a UISearchBar below a header-view. This header is 64px hight. If the searchbar gets touched, the parent view will move 64px up — fine.
After finishing searching the parent view will only move down, as long there is still free space below it. And the top is out of the visible bounds.
But I want to move it back to the original position every time searching finished. How can I achieve it?
Solution
Implement the UISerachDisplayDelegate
-method -searchDisplayControllerDidEndSearch:
like this:
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller{
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow