0

TapForTap iOS SDK を Monotouch C# アプリケーションに移植しようとしています。

ドキュメントとバインディング ジェネレーターを使用して、次のバインディング ApiDefintion を作成しました。

namespace TapForTap {

[BaseType (typeof (NSObject))]
interface TapForTap {
    [...]
    [Static]
    [Export ("initializeWithAPIKey:")]
    void InitializeWithAPIKey (string key);
}

[BaseType (typeof (NSObject))]
[Model]
interface TapForTapAdViewDelegate {
    [Abstract]
    [Export ("rootViewController")]
    UIViewController RootViewController ();

    [...]
}

[BaseType (typeof (UIView))]
interface TapForTapAdView {
    [Static]
    [Export ("initWithFrame:delegate:")]
    NSObject Init (RectangleF frame, TapForTapAdViewDelegate d);

    [Export ("loadAds")]
    void LoadAds ();

    [Export ("stopLoadingAds")]
    void StopLoadingAds ();

            [...]
}
}

私のプロジェクトでは、TapForTapAdViewDelegate を実装するクラス TapForTapDelegate を作成しました。

public partial class TapForTapAdDelegate : TapForTapAdViewDelegate {
    public override UIViewController RootViewController () {
        return Application.mainViewController;
    }

    [...]
}

問題は、initWithFrame:delegate: 関数を正しく実装したかどうか本当にわからないことです。

次のコードを使用しようとするたびに、NSInvalidArgumentException Reason: +[TapForTapAdView initWithFrame:delegate:]: unrecognized selector sent to class 0x36dac4

bannerAd = (TapForTapAdView) TapForTapAdView.Init (new System.Drawing.RectangleF(0, y, 320, 50), new TapForTapAdDelegate());

私は何を間違っていますか?何時間も試しましたが、解決策が見つかりませんでした。私は C# や Objective-C ではなく、Java に慣れています ;)

4

1 に答える 1

2

問題は、init *メソッドがC#コンストラクターとしてバインドされていることです。

これを試して:

[BaseType (typeof (UIView))]
interface TapForTapAdView {
    [Export ("initWithFrame:delegate:")]
    IntPtr Constructor (RectangleF frame, TapForTapAdViewDelegate d);

    ...
}

Xamarin.iOSでObjective-Cライブラリをバインドする方法に関するその他のドキュメントは次のとおりです特に、セクション3.3バインディングコンストラクタを参照してください。

于 2013-03-21T23:17:32.777 に答える