Reputation: 1361
PROBLEM
I want to keep the UISearchBar at the top of my UITableview, but it scrolls away with the list when I scroll down.
I found this post and followed it link
It told me to use this code
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// UISearchBar *searchBar = searchDisplayController.searchBar;
searchBar = self.searchDisplayController.searchBar;
CGRect rect = searchBar.frame;
rect.origin.y = MAX(0, scrollView.contentOffset.y);
searchBar.frame = rect;
}
I may have missed something, but this method is called but the UISearchBar stil disappears.
Upvotes: 2
Views: 3580
Reputation: 318
There is a document from apple developer forum,named "advanced_scroll_view_techniques.pdf",that will help you.
sample code: http://developer.apple.com/library/ios/samplecode/StreetScroller/Introduction/Intro.html
Upvotes: 1
Reputation: 1361
Ok so the solution was A LOT easier than i expected. All i had to do in IB was drag the SearchBar out of the View so it was no longer nested.
Upvotes: 1