【问题标题】:iOS Binding : How to create a binding for a class that implements several delegates?iOS 绑定:如何为实现多个委托的类创建绑定?
【发布时间】:2013-09-26 10:49:57
【问题描述】:

我正在尝试做一个绑定项目,但是我不知道如何绑定下一个接口,它实现了三个不同的委托:

@interface Integration :  NSObject<NSURLConnectionDelegate, SomeControllerDelegate, 
CLLocationManagerDelegate>
{
    id<VendorIntegrationDelegate> delegate;
    Information *Information;
    SomeController * controller;
}

@property(nonatomic,assign) id<VendorIntegrationDelegate> delegate;
@property(nonatomic,strong) Information *Information;
@property(nonatomic,strong) SomeController *controller;

@end

在ApiDefinition.cs中我做了如下绑定,缺少SomeControllerDelegate和CLLocationManagerDelegate的实现:

[BaseType (typeof (NSUrlConnectionDelegate), Delegates=new string [] { "WeakDelegate" },
Events=new Type [] { typeof (VendorIntegrationDelegate)})]
public partial interface Integration
{
    [Export ("delegate", ArgumentSemantic.Assign), NullAllowed]
    NSObject WeakDelegate { get; set; }

    [Wrap("WeakDelegate")]
    VendorIntegrationDelegate Delegate { get; set; }

    [Export ("Information", ArgumentSemantic.Retain)]
    Information Information { get; set; }

    [Export ("controller", ArgumentSemantic.Retain)]
    SomeController  Controller { get; set; }

}

我在做这个绑定时发现的问题是接口继承了几个类,如何创建这个绑定

【问题讨论】:

    标签: ios binding xamarin.ios xamarin


    【解决方案1】:

    如果问题是关于SomeControllerDelegate,则将其声明为[Model],而没有[BaseType],如下所示:

    [Model]
    interface SomeControllerDelegate
    {
        //...
    }
    
    //...
    
    [BaseType (typeof (NSUrlConnectionDelegate), /*...*/]
    interface Integration : SomecontrollerDelegate
    {
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      • 1970-01-01
      • 1970-01-01
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多