Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent UITableView separator color from turning black in UIPopoverController (iOS7)?

My app uses a UITableViewController, which is a child of UINavigationController, which is the content view controller of a UIPopoverController. I am customizing the appearance of the UITableView of the UITableViewController. It works perfectly for iOS 5 and 6, but it has an issue in iOS7. The separators of the cells are set to be white in color, and the table view initially appears with the correct separator color. However, once I scroll the table view and the cells are reloaded (meaning cellForRowAtIndexPath and willDisplayCell functions are called), the separators of the newly reloaded cells are all black.

I am customizing the separator color by calling this function in the UITableViewController's viewDidLoad function:

self.tableView.separatorColor = [UIColor whiteColor];

If I use the exact same table view elsewhere in the app (not in a UIPopoverController), then I do not have this problem.

As far as I can tell, there is nothing in the documentation to indicate that this should work differently for iOS 7 than for 5 or 6. Maybe it's an iOS bug? Any help would be much appreciated.

like image 706
user1021430 Avatar asked Sep 30 '13 16:09

user1021430


2 Answers

set this in viewwillAppear

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
        self.tableView.separatorColor = [UIColor whiteColor];
    }

hope this helps

like image 102
Mahesh Avatar answered Nov 05 '22 21:11

Mahesh


The issue was an iOS bug - the issue no longer occurs for me for iOS7.0.4. I do not know exactly which version it was fixed in. So there's no need to reloadData or set separatorColor in viewWillAppear. It's sufficient to do this in viewDidLoad.

like image 31
user1021430 Avatar answered Nov 05 '22 19:11

user1021430