Separator Insets on UITableView in iOS8 - Xamarin.iOS

In iOS7 it was possible to configure the separator insets by setting the separator inset property on the tableview:

tableView.SeparatorInsets = new UIEdgeInsets(0, 0, 0, 0)

In iOS8 this no longer works and you need to set the LayoutMargins on both the table and the cell remembering to check if the property is supported first to avoid breaking iOS7

if (this.TableView.RespondsToSelector(new Selector("setLayoutMargins:")))
    this.TableView.LayoutMargins = new UIEdgeInsets(0, 0, 0, 0);

Commonly the cell separator insets are set by overriding WillDisplay

public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
{
    if (cell.RespondsToSelector(new Selector("setLayoutMargins:")))
        cell.LayoutMargins = new UIEdgeInsets(0, 0, 0, 0);
}

Hopefully this won't change again with iOS9...

Comments

Popular posts from this blog

How to setup Azure Service Bus Relay to use with ACS

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED