zach
zach

Reputation: 1361

Keeping UISeachBar from dissappearing when scrolling

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

Answers (2)

zach
zach

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

Related Questions