MonoTouch - how to override static UICollectionVie

2019-05-18 09:09发布

I have the opposite problem to this question

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.

I've tried...

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

... but this is never called.

1条回答
地球回转人心会变
2楼-- · 2019-05-18 09:51

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.

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

查看更多
登录 后发表回答