ios - 覆盖方法 `GetSizeForItem` 返回 "no suitable method found to override"

标签 ios xamarin xamarin.ios uicollectionview uicollectionviewcell

我是 Xamarin iOS 开发的新手,我已经开始学习 CollectionView 教程,包括自定义单元格高度。

我想根据单元格的内容更改单元格的高度(例如,单元格是否包含标题)。 我尝试按如下方式开发我的自定义 UICollectionViewFlowLayout 类。

public class TaskFlowLayoutDelegate : UICollectionViewFlowLayout
{
    public TaskFlowLayoutDelegate()
    {
    }

    public override CoreGraphics.CGSize GetSizeForItem(UICollectionView collectionView, UICollectionViewLayout layout, NSIndexPath indexPath)
    {
        return new CoreGraphics.CGSize((float)UIScreen.MainScreen.Bounds.Size.Width, 100)
    }
}

但是,在上面的 GetSizeForItem 函数中,Xamarin IDE 返回找不到要覆盖的合适方法

如何解决?

最佳答案

不确定您是否使用了错误的子类或错误的方法/属性:

UICollectionViewDelegateFlowLayout 有一个带有您尝试使用的签名的 GetSizeForItem 方法。

UICollectionViewFlowLayout 有一个 ItemSize 属性

关于ios - 覆盖方法 `GetSizeForItem` 返回 "no suitable method found to override",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43568245/

相关文章:

c# - Xamarin.Forms如何根据条件绑定(bind)背景颜色

xamarin - 无法在 Xamarin Studio 中引用 PCL 库

c# - 我用什么事件来触发 XAML (Xamarin Forms) 中的 mousedown 之类的事件

ios - layer.addSublayer 与 layer.insertSublayer 动画

iphone - @synchronized(self) 有多少开销?

xamarin.ios - 设置 MonoTouch.Dialog UITableView 位置?

c# - 单点触控 : Hide UIBarButtonItem

iphone - 我可以将 nHibernate 与单点触控一起使用吗?

iOS AssetLibrary 存储指针

ios - 将 block 中的数据保存到 NSMutableDictionary 和一般的 block 中