I have UITableviewController which contains a searchbar at the top and table rows underneath. I've set the navbar to hidden and position the view 20 px from top to account for status bar.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = YES;
UIApplication *app = [UIApplication sharedApplication];
if(!app.statusBarHidden) {
[self.view setFrame:CGRectMake(0.0,app.statusBarFrame.size.height, self.view.bounds.size.width, self.view.bounds.size.height - app.statusBarFrame.size.height)];
}}
This works. When the view first loads, the status bar and the view appear fine.
However, if I tap on one of the tablerows, that transitions to a new pushed view. Upon coming back from the new view to the view which contains the tableview, the statusbar intermingles with the tableviewcontroller view.
The viewdidappear is called but it has no effect. Is there a better way of doing this? In one of my other views, I manually added 20 px in the storyboard. However, with this tableviewcontroller, I couldn't figure out a way of doing that. Any suggestions welcome.
This worked for me.
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.navigationController.navigationBar.hidden = YES;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7){
self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0);
}
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
}