I have a UITableViewController with an imbedded UISearchDisplayController. In iOS 7 the search box is under the status bar. Is there a way in interface builder to offset the tableview so that the search bar is not covered by the status bar (and still use the UITableViewController and UISearchDisplayController setup)?
-
In storyboard have you tried to change the "Status Bar" to None for your viewcontroller? – Sam B Sep 11 '13 at 17:34
-
1Setting the status bar to none in the simulated metrics has no effect when the app is running. – datinc Sep 11 '13 at 18:06
9 Answers
self.edgesForExtendedLayout=UIRectEdgeNone;
should fix this issue.

- 1,046
- 11
- 18
-
1this works if your uitableview is showing up underneath the navigation bar – Jesse Oct 01 '13 at 15:48
-
But now I also have the problem where the uitableview is extending below the bottom tab bar. How would you fix this issue? Yes, I could set the height to end above the tab bar, but then it would not look right with iOS 6 – Jesse Oct 01 '13 at 15:51
-
You can use [[UIScreen mainScreen]bounds] to get your screen height, and then resize UITableView. – Filippo Oct 01 '13 at 20:38
You would have to embed it in a UINavigationController
, then in the navVC
, simply uncheck the Shows Navigation Bar

- 1,139
- 6
- 14
-
1THIS in combination @Filippo's line (self.edgesForExtendedLayout=UIRectEdgeNone; in -viewDidLoad) is what ended up working for me. – Fang Chen Sep 24 '13 at 21:32
-
Feels a bit hacky but this one worked for me:
[self.tableView setContentInset:UIEdgeInsetsMake(self.navigationController.navigationBar.frame.size.height + [[UIApplication sharedApplication] statusBarFrame].size.height, 0, 0, 0)];
and if you're working for both orientations:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[self.tableView setContentInset:UIEdgeInsetsMake(self.navigationController.navigationBar.frame.size.height + [[UIApplication sharedApplication] statusBarFrame].size.height, 0, 0, 0)];
}

- 4,706
- 2
- 21
- 26
-
This did not work for me. Can you explain how setting content inset on tableview changes the frame of the UISearchBar of a UISearchDisplayController? – Fang Chen Sep 24 '13 at 21:23
Place the following code in your viewcontroller's viewdidload.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
}

- 516
- 1
- 5
- 21
self.edgesForExtendedLayout = UIRectEdgeNone;
...
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
if (navigation.hiden) {
[self.tbview setContentOffset:CGPointMake(0, -20)];
[self.tbview setContentInset:UIEdgeInsetsMake(20, 0, 0, 0)];
}
else {
[self.tbview setContentOffset:CGPointMake(0, -20)];
[self.tbview setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
}

- 1,106
- 1
- 12
- 20
I had to adjust the tableview's contentOffset
and contentInset
. My tableviewcontroller triggered by modal segue is already embedded in a navigation controller upstream in the storyboard. Adjusting the content inset by the height of the status bar and content offset by the height of the search bar displays the tableview beginning at the first cell. The search bar displays when the user pulls down the tableview.
self.tableView.contentOffset = CGPointMake(0, 44.0);
self.tableView.contentInset = UIEdgeInsetsMake(20.0, 0.0, 0.0, 0.0);

- 21
- 1
I found the culprit. Setting the layout option "Adjust Scroll View Insets" to on did the trick.

- 3,404
- 3
- 24
- 33
-
11) To what "layout option" are you referring 2) I can not find "Adjust Scroll View Insets" anywhere, can you point my eyes to the right view? Thank you for your help – Fang Chen Sep 17 '13 at 20:13
-
You can see the option in this picture . – datinc Sep 22 '13 at 15:59
-
This only affects a view I have setup in a tabbarcontroller. The option is already on but it has no effect. – Hackmodford Sep 23 '13 at 13:08
All you have to do for this is select the view controller your UITableView is housed in and show the Attributes Inspector. In Attributes Inspector, uncheck Extend Edges -> Under Top Bars and Under Bottom Bars. This worked for me when my UITableview was loading up underneath the Nav bar and Tab Bar

- 2,674
- 6
- 30
- 47
after data loaded into table view just call this in iOS 6 / 7
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
But make sure that the search bar is added as header to the table view

- 627
- 5
- 10