简体   繁体   English

Xamarin.Forms:用于在UITableViewCell上显示公开指示符的自定义渲染器

[英]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.

相关问题 将ViewCell Disclosure Indicator附件添加到Xamarin.Forms Android和Iphone - Adding ViewCell Disclosure Indicator Accessory to Xamarin.Forms Android and Iphone Xamarin.Forms Wysiwyg:使用自定义渲染器将项目从Xamarion.iOS移至Xamarin.Forms - Xamarin.Forms Wysiwyg: move project from Xamarion.iOS to Xamarin.Forms using custom renderer 如何在Xamarin.Forms中为ToolbarItem创建自定义渲染器? - How can I make a custom renderer for ToolbarItem in Xamarin.Forms? Xamarin.Forms中的Droid Custom Picker Renderer错误 - Error with Droid Custom Picker Renderer in Xamarin.Forms 如何从自定义渲染器设置 Xamarin.Forms 元素 BindableProperties? - How to set Xamarin.Forms Elements BindableProperties from a Custom Renderer? 使用Xamarin.Forms自定义渲染器时转发事件/命令 - Forwarding events/commands when using Xamarin.Forms Custom Renderer Xamarin.Forms for WinPhone无法识别自定义选择器渲染器绘制事件 - Custom picker renderer draw event not recognized in Xamarin.Forms for WinPhone 如何创建Xamarin.Forms自定义渲染器,其中渲染器基类使用泛型? - How to create a Xamarin.Forms custom renderer, where the renderer base class uses generics? iOS Xamarin.Forms的Picker渲染器? - Picker renderer for iOS Xamarin.Forms? Xamarin.Forms:使用披露按钮时删除缩进 - Xamarin.Forms: Remove indentation when using a disclosure button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM