Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make table cells and separator full width in iOS 8 with Xamarin?

We have a number of table views (using Xamarin Monotouch Dialog) that are plain (not grouped) and are designed to appear full-width without indents. This all works fine in iOS 7. Using the iOS 8 simulator though, we're getting a slight left indent.

iOS 8 has a new property called LayoutMargins. We're setting that property to zero. Like this:

if (this.TableView.RespondsToSelector(new Selector("setSeparatorInset:")))
    this.TableView.SeparatorInset = UIEdgeInsets.Zero;

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

That had some effect - it removed about half the indent. But we're still seeing a slight indent. Is there another property that controls the indent in iOS 8?

Here's a screenshot... enter image description here

like image 247
Ender2050 Avatar asked Sep 22 '14 19:09

Ender2050


1 Answers

According to this post you need to do this on the UITableView and on your UITableViewCell subclasses.

Another person (same post) overrode the LayoutMargins property on the UITableViewCell subclass to always return UIEdgeInsets.Zero.

like image 110
poupou Avatar answered Nov 17 '22 11:11

poupou