摘要
這是我的第一個應用程序,我試圖用Xamarin。我正在從Hello World, iPhone
的例子中學習。當我點擊我的按鈕時,應用程序崩潰,我無法弄清楚爲什麼。當我點擊我的UIButton時,iOS應用程序崩潰 - 找不到爲什麼?
詳細
我有一個簡單的UIViewController
與單一UIButton
。我創建了一個插座,所以當我點擊按鈕時,我會做一些事情。
當我連接按鈕的TouchUpInside event
時,應用程序崩潰,當我點擊按鈕。當我刪除有線事件(但插座仍然存在),當我點擊按鈕時,應用程序不會崩潰。 (當然,沒有任何事情會發生,因爲沒有連接)。
殺死我的是我不知道什麼是錯誤的,並且使用調試信息,我找不到它!我一直在做C#代碼多年,但剛開始在XAM是有點不同,特別是當崩潰報告是..以及缺乏任何信息:(我猜我可能有一些設置打勾(例如。沒有調試信息?)
因此,這裏的一些代碼...
AuthenticationViewController
.h文件中
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface AuthenticationViewController : UIViewController {
UIButton *_Google;
}
@property (nonatomic, retain) IBOutlet UIButton *Google;
@end
.m文件
#import "AuthenticationViewController.h"
@implementation AuthenticationViewController
@synthesize Google = _Google;
@end
設計文件
using MonoTouch.Foundation;
using System.CodeDom.Compiler;
namespace Foo.Client.iPhone
{
[Register ("AuthenticationViewController")]
partial class AuthenticationViewController
{
[Outlet]
MonoTouch.UIKit.UIButton Google { get; set; }
void ReleaseDesignerOutlets()
{
if (Google != null) {
Google.Dispose();
Google = null;
}
}
}
}
最後,我
.cs文件
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Foo.Client.iPhone
{
public partial class AuthenticationViewController : UIViewController
{
public int xxx = 0;
public event EventHandler OnAuthenticationCompleted;
public AuthenticationViewController()
: base ("AuthenticationViewController", null)
{
}
public override void DidReceiveMemoryWarning()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
Google.TouchUpInside += (sender, e) =>
{
xxx++;
};
}
}
}
哦 - 和錢拍...的(缺乏)崩潰轉儲/堆棧跟蹤
2013-10-25 21:37:13.785 FooClientiPhone[8852:1403] MonoTouch: Socket error while connecting to MonoDevelop on 127.0.0.1:10000: Connection refused
mono-rt: Stacktrace:
mono-rt: at <unknown> <0xffffffff>
mono-rt: at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
mono-rt: at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
mono-rt: at Foo.Client.iPhone.Application.Main (string[]) [0x00008] in /Users/PureKrome/Documents/Mac Projects/Foo iOS Client/Code/Foo.Client.iPhone/Main.cs:16
mono-rt: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
mono-rt:
Native stacktrace:
mono-rt:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
我被卡住了,不知道如何繼續?我已經花了很多時間嘗試各種各樣的事情來實現這個目標。
此外,here's a video showing the error(請選擇720p版本)。
我將不勝感激任何幫助 - >而不是說:在這裏,它是固定的。但是..你沒有做到這一點,並且你需要做這些事情,所以xxxx的作品。
有什麼建議嗎?
在沒有調試的情況下運行應用程序時會發生崩潰嗎? –
是的。它也確實發生。 –