3

Known solutions for hiding the UISearchBar don't work when the table contains just a few rows. For example,

 [self.companiesAndContatsTableView setContentOffset:CGPointMake(0, 44)];

will work only if the number of cells in the table exceed the number of rows that fit on the screen. I want to hide search bar in every situation - especially when the table contains just a few rows and the user doesn't need the search functionality.

I tried to add something like:

self.companiesAndContatsTableView.contentInset = UIEdgeInsetsMake(-44, 0,0, 0);

but I'm not allowed to move the position of my alphabet index section on the right side.

enter image description here

4
  • [yourTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
    – Mohit
    Aug 8, 2014 at 9:52
  • I only need to hide the search bar when user see the controller for the first time, like [self.companiesAndContatsTableView setContentOffset:CGPointMake(0, 44)] method does when there are a lot of cells.
    – mikezs
    Aug 8, 2014 at 10:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.