如何使用Xamarin在iOS 8中制作表格单元格和分隔符全宽?

时间:2014-09-22 19:17:03

标签: c# xamarin.ios xamarin ios8 monotouch.dialog

我们有许多表格视图(使用Xamarin Monotouch对话框),它们是普通的(未分组),并且设计为全宽而不缩进。这一切在iOS 7中运行良好。但是,使用iOS 8模拟器,我们会略微左缩进。

iOS 8有一个名为LayoutMargins的新属性。我们将该属性设置为零。像这样:

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

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

这有一些影响 - 它删除了大约一半的缩进。但我们仍然看到一个轻微的缩进。是否有另一个属性控制iOS 8中的缩进?

这是截图... enter image description here

2 个答案:

答案 0 :(得分:10)

根据此post,您需要在UITableView子类的UITableViewCell 上执行此操作。

另一个人(同一篇文章)覆盖LayoutMargins子类上的UITableViewCell属性,以便始终返回UIEdgeInsets.Zero

答案 1 :(得分:0)

在C#中, tableView.SeparatorInset = UIEdgeInsets.Zero;