C# 表单:使用公开按钮时删除缩进
我想在我的“表格视图”单元格上使用“披露”按钮。因此,我使用此自定义渲染器:C# 表单:使用公开按钮时删除缩进,c#,ios,uitableview,xamarin.ios,xamarin.forms,C#,Ios,Uitableview,Xamarin.ios,Xamarin.forms,我想在我的“表格视图”单元格上使用“披露”按钮。因此,我使用此自定义渲染器: using HelloXamarinFormsWorld; using HelloXamarinFormsWorld.iOS; using UIKit; using System; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; using System.Drawing; using ObjCRuntime; /* Example of using a c
using HelloXamarinFormsWorld;
using HelloXamarinFormsWorld.iOS;
using UIKit;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using System.Drawing;
using ObjCRuntime;
/* Example of using a custom renderer to get the > disclosure indicator to appear */
[assembly: ExportRenderer (typeof (EmployeeCell), typeof (EmployeeCellRenderer))]
namespace HelloXamarinFormsWorld.iOS
{
public class EmployeeCellRenderer : ViewCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var cell = base.GetCell (item, reusableCell, tv);
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
// // Remove seperator inset
// if (cell.RespondsToSelector (new Selector ("setSeparatorInset:"))) {
// cell.SeparatorInset = UIEdgeInsets.Zero;
// }
// // Prevent the cell from inheriting the Table View's margin settings
// if (cell.RespondsToSelector (new Selector ("setPreservesSuperviewLayoutMargins:"))) {
// cell.PreservesSuperviewLayoutMargins = false;
// }
// // Explictly set your cell's layout margins
// if (cell.RespondsToSelector (new Selector ("setLayoutMargins:"))) {
// cell.LayoutMargins = UIEdgeInsets.Zero;
// }
return cell;
}
}
}
如果我设置披露指标,我会看到以下屏幕:
通常情况下,它看起来确实如下所示
我试着玩插图,但那必须在的WillDisplay
中,而且缩进也没有被删除。在马林霍州
您可以通过设置UIEdgeInsets来修复,我想,我使用了上的Padding属性
但我不知道该在哪里做。或者如何修复缩进
编辑:
使用
cell.SeparatorInset=新的UIEDGEINSET(0,0,0)
没有帮助。我想这应该是Xamarin.Forms中的一个bug
查看反编译代码后,发现默认的<>代码> VIEWCELLRUNDER器试图通过计算单元格的内容视图来调整自身,这是不正确的,因为它没有考虑<代码>通知指示符< /代码>的大小。
因此,解决方法是手动插入指示器(ExtendedViewCell就是这样做的),而不使用默认的公开指示器 你的意思是使用一个简单的图像吗?