1
我真的難住了。我有一個視圖與ScrollView它和一個標籤。在這種情況下,滾動工作正常。我放了一個按鈕,創建了clickFoo動作,並且像部分UIViews那樣放入了部分代碼,但是現在它會導致一個可怕的堆棧跟蹤(見下文)。如果我刪除了按鈕和操作,但是放入了UIScrollView的Scrolling事件的處理程序,我會得到相同的結果。我很難過爲什麼會這樣。這真的很簡單,沒有任何意義。MonoTouch - ScrollView +任何事件=崩潰
爲了記錄,滾動視圖是100x40,標籤和按鈕不在滾動視圖中。
我在viewDidLoad中下面的代碼
public partial class Testing : UIViewController
{
#region Constructors
// The IntPtr and initWithCoder constructors are required for items that need
// to be able to be created from a xib rather than from managed code
public Testing (IntPtr handle) : base(handle)
{
Initialize();
}
[Export("initWithCoder:")]
public Testing (NSCoder coder) : base(coder)
{
Initialize();
}
public Testing() : base("Testing", null)
{
Initialize();
}
void Initialize()
{
}
#endregion
List<UIImageView> _imageViews;
public override void ViewDidLoad()
{
base.ViewDidLoad();
_imageViews = new List<UIImageView>();
UIButton btnNumber;
/* btnNumber = new UIButton(new RectangleF(new PointF(32f*x,0f), new SizeF(31f,31f)));
btnNumber.SetImage(UIImage.FromBundle("images/7.png"), UIControlState.Normal);
btnNumber.SetImage(UIImage.FromBundle("images/7.png"), UIControlState.Highlighted);*/
UIImageView imgView;
scrollView.ContentSize = new System.Drawing.SizeF(400, 31);
for (int x=0;x < 30; x++) {
imgView = new UIImageView(new RectangleF(new PointF(32f*x,0f), new SizeF(31f,31f)));
imgView.Image = UIImage.FromBundle("images/7.png");
scrollView.AddSubview(imgView);
_imageViews.Add(imgView);
}
}
partial void clickFoo (UIButton sender)
{
lblInfo.Text = "Clicked";
}
} [ Code pasted in updated @12:07pm EDT ]
我得到下面的異常堆棧(我覺得這是典型的「喂,有事事件相關是錯的,什麼地方」,非常令人沮喪)
Stacktrace:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00004>
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00004>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:31
at ZenVelopes.Application.Main (string[]) [0x00000] in /Users/drisszouak/Projects/ZenVelopes/ZenVelopes/Main.cs:14
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x0001d, 0x00043>
Native stacktrace:
0 ZenVelopes 0x000be9db mono_handle_native_sigsegv + 343
1 ZenVelopes 0x0000e7a6 mono_sigsegv_signal_handler + 313
2 libSystem.B.dylib 0x918db46b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 UIKit 0x01c721b5 -[UIControl sendAction:to:forEvent:] + 67
5 UIKit 0x01c74647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
6 UIKit 0x01c731f4 -[UIControl touchesEnded:withEvent:] + 458
7 UIKit 0x01c080d1 -[UIWindow _sendTouchesForEvent:] + 567
8 UIKit 0x01be937a -[UIApplication sendEvent:] + 447
9 UIKit 0x01bee732 _UIApplicationHandleEvent + 7576
10 GraphicsServices 0x03eb9a36 PurpleEventCallback + 1550
11 CoreFoundation 0x00dfb064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
12 CoreFoundation 0x00d5b6f7 __CFRunLoopDoSource1 + 215
13 CoreFoundation 0x00d58983 __CFRunLoopRun + 979
14 CoreFoundation 0x00d58240 CFRunLoopRunSpecific + 208
15 CoreFoundation 0x00d58161 CFRunLoopRunInMode + 97
16 GraphicsServices 0x03eb8268 GSEventRunModal + 217
17 GraphicsServices 0x03eb832d GSEventRun + 115
18 UIKit 0x01bf242e UIApplicationMain + 1160
19 ??? 0x09e28c41 0x0 + 165841985
20 ??? 0x09e28b7a 0x0 + 165841786
21 ??? 0x09e2857d 0x0 + 165840253
22 ??? 0x09e284b9 0x0 + 165840057
23 ??? 0x09e28514 0x0 + 165840148
24 ZenVelopes 0x0000e56a mono_jit_runtime_invoke + 1360
25 ZenVelopes 0x001c961b mono_runtime_invoke + 137
26 ZenVelopes 0x001cb2d7 mono_runtime_exec_main + 714
27 ZenVelopes 0x001cabfd mono_runtime_run_main + 812
28 ZenVelopes 0x00095354 mono_jit_exec + 200
29 ZenVelopes 0x0027d299 main + 3494
30 ZenVelopes 0x00003009 _start + 208
31 ZenVelopes 0x00002f38 start + 40
Debug info from gdb:
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-x86.double-abi-stret-trampoline.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-x86.double-abi-stret-trampoline.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(gc.x86.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(gc.x86.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(zlib-helper.x86.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(zlib-helper.x86.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: Could not find object file "/var/folders/Ny/NyElTwhDGD8kZMqIEeLGXE+++TI/-Tmp-//ccvRqNHg.o" - no debug information available for "template.m".
warning: .o file "/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_divdi3.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_divdi3.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: .o file "/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_moddi3.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_moddi3.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: .o file "/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_udivdi3.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_udivdi3.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
warning: .o file "/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_umoddi3.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Could not open OSO file /Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_umoddi3.o) to scan for pubtypes for objfile /Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes
Error connecting stdout and stderr (127.0.0.1:10001)
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)" more recent than executable timestamp in "/Users/drisszouak/Library/Application Support/iPhone Simulator/4.2/Applications/F902A6B1-4BA7-4BBE-B9D0-E5E4FE33A55A/ZenVelopes.app/ZenVelopes"
warning: Couldn't open object file '/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)'
Attaching to process 3839.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ...................................................................................................................... done
0x91880459 in read$UNIX2003()
7 "WebThread" 0x918750fa in mach_msg_trap()
6 0x918a30a6 in __semwait_signal()
5 0x91875136 in semaphore_wait_trap()
4 0x918750fa in mach_msg_trap()
3 0x9189aa12 in __workq_kernreturn()
2 "com.apple.libdispatch-manager" 0x9189b982 in kevent()
* 1 "com.apple.main-thread" 0x91880459 in read$UNIX2003()
Thread 7 (process 3839):
#0 0x918750fa in mach_msg_trap()
#1 0x91875867 in mach_msg()
#2 0x00dfb4a6 in __CFRunLoopServiceMachPort()
#3 0x00d58874 in __CFRunLoopRun()
#4 0x00d58240 in CFRunLoopRunSpecific()
#5 0x00d58161 in CFRunLoopRunInMode()
#6 0x04f7e423 in RunWebThread()
#7 0x918a285d in _pthread_start()
#8 0x918a26e2 in thread_start()
Thread 6 (process 3839):
#0 0x918a30a6 in __semwait_signal()
#1 0x918ceee5 in nanosleep$UNIX2003()
#2 0x918cee23 in usleep$UNIX2003()
#3 0x002774e0 in monotouch_pump_gc()
#4 0x918a285d in _pthread_start()
#5 0x918a26e2 in thread_start()
Thread 5 (process 3839):
#0 0x91875136 in semaphore_wait_trap()
#1 0x0015b189 in finalizer_thread (unused=0x0) at ../../../../mono/metadata/gc.c:1026
#2 0x00203836 in start_wrapper (data=0x7b172e0) at ../../../../mono/metadata/threads.c:661
#3 0x00244c76 in thread_start_routine (args=0x8034a34) at ../../../../mono/io-layer/wthreads.c:286
#4 0x002746eb in GC_start_routine (arg=0x6ff8f60) at ../../../libgc/pthread_support.c:1390
#5 0x918a285d in _pthread_start()
#6 0x918a26e2 in thread_start()
Thread 4 (process 3839):
#0 0x918750fa in mach_msg_trap()
#1 0x91875867 in mach_msg()
#2 0x0011cfb2 in mach_exception_thread (arg=0x0) at ../../../../mono/mini/mini-darwin.c:138
#3 0x918a285d in _pthread_start()
#4 0x918a26e2 in thread_start()
Thread 3 (process 3839):
#0 0x9189aa12 in __workq_kernreturn()
#1 0x9189afa8 in _pthread_wqthread()
#2 0x9189abc6 in start_wqthread()
Thread 2 (process 3839):
#0 0x9189b982 in kevent()
#1 0x9189c09c in _dispatch_mgr_invoke()
#2 0x9189b559 in _dispatch_queue_invoke()
#3 0x9189b2fe in _dispatch_worker_thread2()
#4 0x9189ad81 in _pthread_wqthread()
#5 0x9189abc6 in start_wqthread()
Thread 1 (process 3839):
#0 0x91880459 in read$UNIX2003()
#1 0x000beb8b in mono_handle_native_sigsegv (signal=11, ctx=0xbfffd294) at ../../../../mono/mini/mini-exceptions.c:1826
#2 0x0000e7a6 in mono_sigsegv_signal_handler (_dummy=10, info=0xbfffd254, context=0xbfffd294) at ../../../../mono/mini/mini.c:4846
#3 <signal handler called>
#4 0x028d8a67 in objc_msgSend()
#5 0x0cbabd70 in ??()
#6 0x01c721b5 in -[UIControl sendAction:to:forEvent:]()
#7 0x01c74647 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]()
#8 0x01c731f4 in -[UIControl touchesEnded:withEvent:]()
#9 0x01c080d1 in -[UIWindow _sendTouchesForEvent:]()
#10 0x01be937a in -[UIApplication sendEvent:]()
#11 0x01bee732 in _UIApplicationHandleEvent()
#12 0x03eb9a36 in PurpleEventCallback()
#13 0x00dfb064 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__()
#14 0x00d5b6f7 in __CFRunLoopDoSource1()
#15 0x00d58983 in __CFRunLoopRun()
#16 0x00d58240 in CFRunLoopRunSpecific()
#17 0x00d58161 in CFRunLoopRunInMode()
#18 0x03eb8268 in GSEventRunModal()
#19 0x03eb832d in GSEventRun()
#20 0x01bf242e in UIApplicationMain()
#21 0x09e28c41 in ??()
#22 0x09e28b7a in ??()
#23 0x09e2857d in ??()
#24 0x09e284b9 in ??()
#25 0x09e28514 in ??()
#26 0x0000e56a in mono_jit_runtime_invoke (method=0x818564c, obj=0x0, params=0xbfffed6c, exc=0x0) at ../../../../mono/mini/mini.c:4733
#27 0x001c961b in mono_runtime_invoke (method=0x818564c, obj=0x0, params=0xbfffed6c, exc=0x0) at ../../../../mono/metadata/object.c:2615
#28 0x001cb2d7 in mono_runtime_exec_main (method=0x818564c, args=0x9e857f0, exc=0x0) at ../../../../mono/metadata/object.c:3581
#29 0x001cabfd in mono_runtime_run_main (method=0x818564c, argc=0, argv=0xbfffeea4, exc=0x0) at ../../../../mono/metadata/object.c:3355
#30 0x00095354 in mono_jit_exec (domain=0x6f91e58, assembly=0x6e1ce80, argc=1, argv=0xbfffeea0) at ../../../../mono/mini/driver.c:1094
#31 0x0027d299 in main()
=================================================================
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.
=================================================================
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
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) [0x00038] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:31
at ZenVelopes.Application.Main (System.String[] args) [0x00000] in /Users/drisszouak/Projects/ZenVelopes/ZenVelopes/Main.cs:14
我看不到有什麼可以收集。我在列表中添加了UIViewController的屬性,但它不會更改任何內容。只有發生任何事件時纔會出現問題。當你說'控制器片段'時,你的意思是UIViewController?他沒有收集。 –
2011-03-29 15:50:10
正如我的回答中所述,這是正在發生的事情,我無法告訴你2%的項目代碼在哪裏。 – 2011-03-29 15:54:08
我剛剛更新了顯示的代碼,使其具有整個部分類,而不是更多顯示。你想要Main.cs的內容嗎?它所具有的只是上面的Testing類的實例化,並將其作爲SubView添加。 – 2011-03-29 16:08:39