lordykw
lordykw

Reputation: 11

UITableView overlapping with Status and Navigation bar when returning from detail view

As mentioned, on initializing the TableView works just fine.

Initial View

I used this code in the detail view to clear the status bar:

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                                              forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
self.navigationController.view.backgroundColor = [UIColor clearColor];

After returning from the DetailView, something like this happens:

View after returning from detail

I tried self.tableView.contentInset in - (void)viewDidLoad and - (void)viewDidAppear and it's not working.

The initial ViewController is a subclass of UITableViewController, not UIViewController.

Upvotes: 1

Views: 1848

Answers (2)

dadalar
dadalar

Reputation: 644

Both view controllers are probably inside the same UINavigationController. That means they share the same UINavigationBar also. You need to set initial values of navigationBar, when returning back to initial view controller. Right now, when you return back, cells overlap with navigation bar because bar is translucent. Set back those values on first view controllers -viewWillAppear method.

self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.backgroundColor = #BARCOLOR;

Upvotes: 2

iHulk
iHulk

Reputation: 4909

set the property self.navigationController.navigationBar.translucent to NO. I mean replace the code self.navigationController.navigationBar.translucent = YES;

With

self.navigationController.navigationBar.translucent = NO;

hope this should work.

Upvotes: 1

Related Questions