我刚刚将我的 Monotouch 升级到 6,现在我的应用程序无法启动。它以前可以正常工作,没有任何问题。现在它在 Main.cs 文件中引发异常(如下所列)。我查看了 Xamarin 上的故障排除提示,但没有解决问题。我重新布置了笔尖文件,删除并重新配置了我的插座,并创建了一个全新的笔尖,看看这是否能解决问题。其他人有什么想法吗?
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSUnknownKeyException Reason: [<UIApplication 0xc84bb10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnNewAccount.
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at Pokr.Application.Main (System.String[] args) [0x00000] in /Users/James/Projects/App/Main.cs:17
LoginView.designer.cs 中的代码:
[Register ("LoginView")]
partial class LoginView
{
[Outlet]
MonoTouch.UIKit.UIImageView imgLogo { get; set; }
[Outlet]
MonoTouch.UIKit.UITextField txtEmail { get; set; }
[Outlet]
MonoTouch.UIKit.UITextField txtPassword { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton btnLogin { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton btnNewAccount { get; set; }
[Outlet]
MonoTouch.UIKit.UILabel lblSecurityNotice { get; set; }
[Outlet]
MonoTouch.UIKit.UIImageView imgKeyboardBorder { get; set; }
void ReleaseDesignerOutlets ()
{
if (imgLogo != null) {
imgLogo.Dispose ();
imgLogo = null;
}
if (txtEmail != null) {
txtEmail.Dispose ();
txtEmail = null;
}
if (txtPassword != null) {
txtPassword.Dispose ();
txtPassword = null;
}
if (btnLogin != null) {
btnLogin.Dispose ();
btnLogin = null;
}
if (btnNewAccount != null) {
btnNewAccount.Dispose ();
btnNewAccount = null;
}
if (lblSecurityNotice != null) {
lblSecurityNotice.Dispose ();
lblSecurityNotice = null;
}
if (imgKeyboardBorder != null) {
imgKeyboardBorder.Dispose ();
imgKeyboardBorder = null;
}
}
Main.cs 中的代码(代码中断的地方):
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
这是我调用 ViewController 的 AppDelegate 的片段:
var rootNavigationController = new UINavigationController();
LoginView loginScreen = new LoginView();
rootNavigationController.PushViewController(loginScreen, false);
this.window.RootViewController = rootNavigationController;
//blank function fires so the getter will init the singleton.
Singleton.Instance.Initialize();
// make the window visible
window.MakeKeyAndVisible ();
return true;