我想加载一个视图控制器包含在一个引用的库以及一个单独的资产包。为了做到这一点,我相信我需要使用initWithNibName方法。我已经添加了以下额外的mTouch参数:MonoTouch UIViewController initWithNibName
-v -v -v -gcc_flags "-L${TargetDir} -F${TargetDir} -F${ProjectDir} -F${TargetDir}/Test.embeddedframework -framework Test"
这种Objective-C的片段不正是我需要做的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSBundle *myBundle = [NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/Test.embeddedframework",[[NSBundle mainBundle] bundlePath]]];
NSString *nib = [myBundle pathForResource:@"TestViewController" ofType:@"nib"];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:myBundle];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
从内MonoTouch的,我已经能够加载编译和绑定加载资产包。但我不知道如何发送消息'initWithNibName'。 API文档对于此方法并不完整,但在UIViewController上显示一个构造函数,它将接受nib名称和包。但是,这似乎并未包含在生成的DLL中。
有没有人有做这样的事情的任何经验或有任何建议,如何能够实现?
感谢您的链接,我以前没有遇到过。但是,这似乎并没有多大帮助。我看到构造函数被定义,与API文档中的相同 - 但我仍然没有在生成的dll中看到这个。我确实为该类创建了绑定,但由于消息“initWithNibName”直接位于UIViewController上,因此我没有定义自己的绑定。这是一个错误吗? 基本上我的api.cs类几乎是空的,因为我现在除了扩展UIViewController外什么都没做。我为控制器定义了一个接口,但没有附加的实例方法。让运行正常。 – 2011-12-29 09:02:12
我接受了建议,并特别添加了如下绑定的构造函数:[Export(“initWithNibName:bundle:”)] IntPtr Constructor(string nibName,NSBundle bundle);但是当我尝试使用它时,我得到:无法在bundle中加载NIB:'NSBundle <..../TestHarness.app/Test.embeddedframework>(尚未加载)',名称为'TestViewController.nib'我一直在在过去的这个错误,并没有一个解决方案 - 任何进一步的建议?再次感谢 – 2011-12-30 05:09:20