MonoTouch-ScrollView +任何事件=崩溃 [英] MonoTouch - ScrollView + Any event = Crash
问题描述
我真的很沮丧.我有一个带有ScrollView的视图和一个标签.在这种情况下,滚动效果很好.我按了一个按钮,创建了clickFoo动作,并像在几十个UIView上一样输入了Partial代码,但是现在它导致了可怕的stacktrace(请参见下文).如果删除按钮和动作,但为UIScrollView的Scrolling事件添加处理程序,我将得到相同的结果.我很困惑为什么会这样.这真的是非常简单的东西,没有任何意义.
I'm really stumped. I have a View with ScrollView on it and a label. The scrolling works fine when this is the case. I put on a button, created the clickFoo action, and put in the Partial code like I have on dozens of UIViews, but now it causes a horrific stacktrace (see below). I get the same if I remove the button and action but put in a handler for the Scrolling event of the UIScrollView. I'm stumped why this is happening. This is really, really simple stuff, makes no sense.
对于记录,滚动视图为100x40,标签和按钮不在滚动视图中.
For the record, the scrollview is 100x40, and the label and button are NOT in the scrollview.
我的ViewDidLoad中包含以下代码
I have the following code in my 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 ]
我得到以下异常堆栈(我发现这是经典的嘿,某事相关的错误,某处",非常令人沮丧)
I get the following exception stack (which I find is the classic "Hey, SOMETHING EVENT RELATED is wrong, somewhere", very frustrating)
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
推荐答案
您没有提供足够的上下文来确切地告诉您什么,但是您正在向其中发送操作消息的对象之一(可能是您发布的控制器代码段),已被收集.
You havn't provided enough context to tell you exactly what, but one of the objects you're sending an action message TO, likely the controller snippet you posted, has been collected.
这篇关于MonoTouch-ScrollView +任何事件=崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!