Xamarin iOS UICollectionView.CellRegistration 带有泛型,它在哪里?

Posted

技术标签:

【中文标题】Xamarin iOS UICollectionView.CellRegistration 带有泛型,它在哪里?【英文标题】:Xamarin iOS UICollectionView.CellRegistration with generic, where is it? 【发布时间】:2021-04-15 05:18:50 【问题描述】:

我一直试图找出 UICollectionView.CellRegistration 的确切位置。

我可以看到有一个 UICollectionViewCellRegistration.GetRegistration,但我不确定如何调用通用版本或至少为 GetRegistration 提供一个 ItemType。

【问题讨论】:

【参考方案1】:

引用官方docs:

   public class UICollectionViewCellRegistration : Foundation.NSObject, Foundation.INSObjectProtocol, ObjCRuntime.INativeObject, System.IDisposable, System.IEquatable<Foundation.NSObject> 
        // constructors
        protected UICollectionViewCellRegistration (Foundation.NSObjectFlag t);
        protected UICollectionViewCellRegistration (IntPtr handle);
        // properties
        public virtual ObjCRuntime.Class CellClass  get; 
        public virtual UINib CellNib  get; 
        public System.Type CellType  get; 
        public override IntPtr ClassHandle  get; 
        public virtual UICollectionViewCellRegistrationConfigurationHandler ConfigurationHandler  get; 
        // methods
        public static UICollectionViewCellRegistration GetRegistration (ObjCRuntime.Class cellClass, UICollectionViewCellRegistrationConfigurationHandler configurationHandler);
        public static UICollectionViewCellRegistration GetRegistration (System.Type cellType, UICollectionViewCellRegistrationConfigurationHandler configurationHandler);
        public static UICollectionViewCellRegistration GetRegistration (UINib cellNib, UICollectionViewCellRegistrationConfigurationHandler configurationHandler);
    

public sealed delegate UICollectionViewCellRegistrationConfigurationHandler : System.MulticastDelegate, System.ICloneable, System.Runtime.Serialization.ISerializable 
    // constructors
    public UICollectionViewCellRegistrationConfigurationHandler (object object, IntPtr method);
    // methods
    public virtual System.IAsyncResult BeginInvoke (UICollectionViewCell cell, Foundation.NSIndexPath indexPath, Foundation.NSObject item, System.AsyncCallback callback, object object);
    public virtual void EndInvoke (System.IAsyncResult result);
    public virtual void Invoke (UICollectionViewCell cell, Foundation.NSIndexPath indexPath, Foundation.NSObject item);

例如:

        var c = UICollectionViewCellRegistration.GetRegistration(typeof(UICollectionViewListCell), (cell, index,item)=>  
        
        );

【讨论】:

以上是关于Xamarin iOS UICollectionView.CellRegistration 带有泛型,它在哪里?的主要内容,如果未能解决你的问题,请参考以下文章

Xamarin SQLite教程Xamarin.iOS项目添加引用

Xamarin.Forms 是 Xamarin.Android、Xamarin.IoS 和 Xamarin.Win 的简单总和吗?

使用Xamarin Effect删除Xamarin.iOS中TextEntry上的圆角

Xamarin.iOS 和 RFComm

Xamarin.IOS 和 Signalr 推送通知

有哪些ios或android应用是用xamarin开发的