我正在尝试将Cordova导出到Monotouch。在大多数情况下它正在工作,但我遇到的问题是CDVViewController
(从UIViewController派生的)的委托方法不会触发。中定义的委托方法CDVViewController
和我定义Monotouch的事件(即派生自 的类CDVViewController
)似乎都不会触发。
这是一些代码;我尝试导出的Cordova代码的第一个片段:
CDVViewController.h:
@interface CDVViewController : UIViewController<UIWebViewDelegate, CDVCommandDelegate> {
}
@property (nonatomic, strong) CDVCordovaView* webView;
CDVViewController.m:
@implementation CDVViewController
@synthesize webView;
- (void) viewDidLoad
{
[super viewDidLoad];
NSLog(@"%s","Cordova viewDidLoad");
}
我的btouch定义如下:
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Omnimove.Web.Cordova
{
[BaseType(typeof(UIWebView))]
interface CDVCordovaView
{
}
[BaseType (typeof (UIViewController))]
interface CDVViewController
{
[Export ("webView")]
CDVCordovaView WebView { get; set; }
}
}
这是我从Monotouch中的CDVViewController派生的类:
public class UIFormsViewController : CDVViewController
{
public override void ViewDidLoad ()
{
Console.WriteLine (@"UIFormsViewController ViewDidLoad()");
base.ViewDidLoad ();
}
}
正如我在开头提到的,代码确实编译并且UIFormsViewController确实显示了它包含的CDVCordovaView ( UIWebView ),但是UIFormsViewController中定义的ViewDidLoad和CDVViewController 中定义的viewDidLoad似乎根本没有触发。谁能解释这是为什么以及我将如何纠正这个问题?