[英]Xamarin.Forms: Custom renderer for displaying disclosure indicator on UITableViewCell
I want to show a disclosure indicator on my table view cell for iOS. 我想在iOS的表格视图单元格上显示一个披露指示器。 I found this thread and a custom renderer has been proposed. 我发现这个线程和自定义渲染器已被提出。 I tried this: 我试过这个:
[assembly: ExportRenderer (typeof (EmployeeCell), typeof (EmployeeCellRenderer))]
namespace HelloXamarinFormsWorld.iOS
{
public class EmployeeCellRenderer : Xamarin.Forms.Platform.iOS.ViewCellRenderer
{
public override UITableViewCell GetCell (Cell item, UITableView tv)
{
var cell = base.GetCell (item, tv);
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
return cell;
}
}
}
This file is called EmployeeCellRenderer
and can be found in the root directory of the iOS solution. 此文件名为EmployeeCellRenderer
,可以在iOS解决方案的根目录中找到。 Such a custom renderer can be also found here . 这样的自定义渲染器也可以在这里找到。
If I want to compile this I get 如果我想编译这个我得到
Error CS0115: `HelloXamarinFormsWorld.iOS.EmployeeCellRenderer.GetCell(Xamarin.Forms.Cell, UIKit.UITableView)' is marked as an override but no suitable method found to override (CS0115) (HelloXamarinFormsWorld.iOS) 错误CS0115:`HelloXamarinFormsWorld.iOS.EmployeeCellRenderer.GetCell(Xamarin.Forms.Cell,UIKit.UITableView)'被标记为覆盖但没有找到合适的方法来覆盖(CS0115)(HelloXamarinFormsWorld.iOS)
These are my includes: 这些是我的包括:
using System;
using HelloXamarinFormsWorld;
using Xamarin.Forms;
using HelloXamarinFormsWorld.iOS;
using UIKit;
How can I add a disclosure indicator to my table view cell? 如何向表格视图单元格添加披露指示符?
The signature of the GetCell()
method changed. GetCell()
方法的签名已更改。 It is now: 就是现在:
public override UIKit.UITableViewCell GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
{
return base.GetCell (item, reusableCell, tv);
}
The reason for the change is the support for reusing cells. 改变的原因是支持重用细胞。
The easiest way to figure these things out is to simply type override
in your code file, followed by a blank (space). 解决这些问题的最简单方法是在代码文件中键入override
,然后输入空格(空格)。 Intellisense will then show all overridable methods of the base class(es). 然后,Intellisense将显示基类的所有可覆盖方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.