jam*_*ar2 17 c# interface-builder xamarin.ios ios ios6
我刚刚将Monotouch升级到6,现在我的应用程序无法启动.它以前没有任何问题.现在它在Main.cs文件中抛出一个异常(如下所示).我已经查看了有关Xamarin的疑难解答提示,但它没有解决问题.我重新布置了nib文件,删除并重新配置了我的插座,并创建了一个全新的笔尖,看看是否可以解决问题.有没有人有任何想法?
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
Run Code Online (Sandbox Code Playgroud)
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;
}
}
Run Code Online (Sandbox Code Playgroud)
来自Main.cs的代码(代码中断的地方):
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
Run Code Online (Sandbox Code Playgroud)
这是我的AppDelegate的片段,我调用了ViewController:
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;
Run Code Online (Sandbox Code Playgroud)
fuz*_*uzz 18
初始化ViewControllerin代码但也ViewController从XIB文件初始化时,会发生此错误.
如果您将"主界面"值设置为ViewController您在代码中创建的值,则可能会发生这种情况.要解决此问题,请将此值ViewController设为空,然后不会自动初始化.
还要检查pInfo文件以查看是否有主界面设置.
感谢@Bart为Xamarin用户提供此提示:
右键单击Xamarin Studio中的项目(v.4)选择'Options',然后在'iOS Project'(部分'iPad Deployment info')下.清除下拉列表'Main Interface',这应该可以解决问题.
| 归档时间: |
|
| 查看次数: |
5918 次 |
| 最近记录: |