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

2

10

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

Exhibitive answered 22/9, 2014 at 19:17 Comment(1)
Anyone have code for how to do this with xamarin.forms for ios?Dannica
D
10

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.

Desmund answered 22/9, 2014 at 20:55 Comment(1)
This worked great. That's twice today you've answered my question! Thanks again...Exhibitive
S
0

In c#, tableView.SeparatorInset = UIEdgeInsets.Zero;

Stefaniestefano answered 22/5, 2019 at 19:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.