dthagard
dthagard

Reputation: 853

Remove IUTableView Separator Using Custom TableCell in MonoDevelop

Ok, I can't for the life of me figure out how to remove the separator or set the background color for a custom UITableCell using MonoDevelop. I'm sure that I'm setting some value somewhere that is overriding my attempts, but I'm clueless as to where that may be.

I've tried following the linked questions to no avail:

In a nutshell, I've a custom class that inherits from UITableViewCell. In that class using the IB I've set the background color to RGB(235, 240, 242). I've also a storyboard that has a custom class that inherits from UITableViewController where in the IB I set the separator style to none and the separator color to Clear. I also set the background color to RGB(235, 240, 242). Despite this, I keep seeing a background color of white for the table cells with a separator between each cell.

I next tried setting the background color in the UITableViewCell constructor. I've also tried setting the separator and background in the UITableViewController class as well:

public partial class NavTableViewController : UITableViewController
{

...

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        this.TableView.SeparatorColor = UIColor.Clear;
        this.TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
        this.TableView.BackgroundColor = UIColor.FromRGB(235, 240, 242);
    } // ViewDidLoad

EDIT Below are some screenshots of what I'm currently getting along with the IB settings. I guess I should also mention (though I don't see how this would affect anything) that the Table View Controller is inside of a View Container.

Results

Table View Configuration

Upvotes: 0

Views: 238

Answers (2)

dthagard
dthagard

Reputation: 853

It appears that moving the code from ViewDidLoad to ViewWillAppear inside the custom UIViewTableController fixed the issue. It didn't seem to matter what the UITableViewStyle used (Plain or Grouped). The only caveat is that there was still left a 1 pixel border between the cells with the color of the background of the table, but for my purposes that is okay.

Upvotes: 0

Eric
Eric

Reputation: 472

It only works if the Table is UITableViewStyle.Grouped.

I've seen the behavior you are seeing (setting the background color)

Upvotes: 0

Related Questions