【问题标题】:Override method `GetSizeForItem` returns "no suitable method found to override"覆盖方法`GetSizeForItem`返回“找不到合适的方法来覆盖”
【发布时间】:2017-04-23 06:52:56
【问题描述】:

我是 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)
    }
}

但是,Xamarin IDE 在上面的 GetSizeForItem 函数中返回 no suitable method found to override

如何解决?

【问题讨论】:

    标签: ios xamarin xamarin.ios uicollectionview uicollectionviewcell


    【解决方案1】:

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

    UICollectionViewDelegateFlowLayout 有一个 GetSizeForItem 方法,其中包含您尝试使用的签名。

    UICollectionViewFlowLayout 有一个ItemSize 属性

    【讨论】:

    • 感谢您的建议。我使用了错误的子类。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多