本文介绍了MonoTouch - 如何覆盖静态 UICollectionViewLayout.layoutAttributesClass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与此相反的问题问题

与 UIView 不同,monotouch 省略了静态方法 layerClass 的定义,大概是为了让您在子类中定义它, layoutAttributesClass 在 UICollectionViewLayout 中定义,我不知道如何在我的子类中覆盖它.

Unlike UIView, where monotouch has omitted the definition of the static method layerClass, presumedly to allow you to define it in a subclass, layoutAttributesClass is defined in UICollectionViewLayout and I have no idea how to override it in my subclass.

我试过了...

    [Export ("layoutAttributesClass")]
    public static Class LayoutAttributesClass {
        get { return new Class(typeof(MyClass)); }
    }

...但这从来没有被调用过.

... but this is never called.

推荐答案

这确实有效,不要让 hides 继承的成员警告让您失望(就像我所做的那样)-您可以使用 new 运算符来摆脱它它仍然有效.

This actually works, don't let the hides inherited member warning throw you off (like I did) -you can use the new operator to get rid of it and it still works.

如果你沿着这条路线走,真正的问题是在你的 UICollectionViewLayoutAttributes 子类上实现 copyWithZone,因为 Xamarin 相当缺乏对此的支持

The real problem if you go down this route is implementing copyWithZone on your UICollectionViewLayoutAttributes subclass as support for this is fairly lacking in Xamarin

这篇关于MonoTouch - 如何覆盖静态 UICollectionViewLayout.layoutAttributesClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:18