iphone - 在单点触控中以模态方式显示 View Controller

标签 iphone ios xamarin.ios

在我基于 Monotouch 的 iOS 项目中,我有 2 个 View Controller 。在第一个 ViewController 上,我通过 xib 创建了一个按钮。 现在,在选择此按钮时,我想显示第二个 View Controller ,但它没有发生,并且导致应用程序崩溃。

所以在我的 design.cs 文件中,这就是创建按钮的方式

[Outlet]
MonoTouch.UIKit.UIButton firstButton { get; set; }

[Action ("clickMe:")]
partial void clickMe (MonoTouch.Foundation.NSObject sender);

这是我的 .cs 文件中的按钮操作方法,导致崩溃。

partial void clickMe (MonoTouch.Foundation.NSObject sender)

{

SecondViewController secondViewControllerObject=new SecondViewController();

this.PresentViewController(secondViewControllerObject, true, null);

}

错误描述:-

执行 native 代码时获得 SIGABRT。

由于未处理的异常而终止运行时

Unhandled Exception:
0   TestingFirstProject                 0x0008ebce mono_handle_exception_internal_first_pass + 2190
1   TestingFirstProject                 0x00090612 mono_handle_exception_internal + 1602
2   TestingFirstProject                 0x0009115f mono_handle_exception + 47
3   TestingFirstProject                 0x000d42b2 mono_x86_throw_exception + 306
4   ???                                 0x0b496f8f 0x0 + 189362063
5   TestingFirstProject                 0x00215f38 monotouch_exception_handler + 136
6   CoreFoundation                      0x013ca318 __handleUncaughtException + 728
7   libobjc.A.dylib                     0x0401d0b9 _ZL15_objc_terminatev + 86
8   libc++abi.dylib                     0x0435ea65 _ZL19safe_handler_callerPFvvE + 13
9   libc++abi.dylib                     0x0435eacd __cxa_bad_typeid + 0
10  libc++abi.dylib                     0x0435fbc2 _ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception + 0
11  libobjc.A.dylib                     0x0401cf89 _ZL26_objc_exception_destructorPv + 0
12  CoreFoundation                      0x013c9fb1 -[NSException raise] + 17
13  Foundation                          0x01a08711 -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
14  Foundation                          0x01989ec8 _NSSetUsingKeyValueSetter + 140
15  Foundation                          0x019899b7 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
16  Foundation                          0x019b4428 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
17  UIKit                               0x029410cc -[UIRuntimeOutletConnection connect] + 106
18  libobjc.A.dylib                     0x04030663 -[NSObject performSelector:] + 62
19  CoreFoundation                      0x0133c45a -[NSArray makeObjectsPerformSelector:] + 314
20  UIKit                               0x0293fbcf -[UINib instantiateWithOwner:options:] + 1327
21  UIKit                               0x02804e37 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
22  UIKit                               0x02805418 -[UIViewController loadView] + 302
23  UIKit                               0x02805648 -[UIViewController loadViewIfRequired] + 73
24  UIKit                               0x02805882 -[UIViewController view] + 33
25  UIKit                               0x02811235 -[UIViewController shouldAutorotate] + 36
26  UIKit                               0x02a103d2 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1933
27  UIKit                               0x0280e4f3 -[UIViewController presentViewController:withTransition:completion:] + 4521
28  UIKit                               0x0280e777 -[UIViewController presentViewController:animated:completion:] + 112
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr_bool_IntPtr (intptr,intptr,intptr,bool,intptr) <IL 0x00016, 0x00044>
at MonoTouch.UIKit.UIViewController.PresentViewController (MonoTouch.UIKit.UIViewController,bool,MonoTouch.Foundation.NSAction) [0x0006f] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:659
at TestingFirstProject.TestingFirstProjectViewController.clickMe (MonoTouch.Foundation.NSObject) [0x00006] in /Users/rock/Desktop/Sample Project/TestingFirstProject/TestingFirstProject/TestingFirstProjectViewController.cs:41
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <IL 0x0004b, 0x0007d>
33  TestingFirstProject                 0x00009922 mono_jit_runtime_invoke + 722
34  TestingFirstProject                 0x0016c4ae mono_runtime_invoke + 126
35  TestingFirstProject                 0x0020f086 monotouch_trampoline + 3686
36  libobjc.A.dylib                     0x04030705 -[NSObject performSelector:withObject:withObject:] + 77
37  UIKit                               0x02727920 -[UIApplication sendAction:to:from:forEvent:] + 96
38  UIKit                               0x027278b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
39  UIKit                               0x027e8671 -[UIControl sendAction:to:forEvent:] + 66
40  UIKit                               0x027e8bcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
41  UIKit                               0x027e7d38 -[UIControl touchesEnded:withEvent:] + 546
42  UIKit                               0x0275733f -[UIWindow _sendTouchesForEvent:] + 846
43  UIKit                               0x02757552 -[UIWindow sendEvent:] + 273
44  UIKit                               0x027353aa -[UIApplication sendEvent:] + 436
45  UIKit                               0x02726cf8 _UIApplicationHandleEvent + 9874
46  GraphicsServices                    0x04d0fdf9 _PurpleEventCallback + 339
47  GraphicsServices                    0x04d0fad0 PurpleEventCallback + 46
48  CoreFoundation                      0x012b6bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
49  CoreFoundation                      0x012b6962 __CFRunLoopDoSource1 + 146
50  CoreFoundation                      0x012e7bb6 __CFRunLoopRun + 2118
51  CoreFoundation                      0x012e6f44 CFRunLoopRunSpecific + 276
52  CoreFoundation                      0x012e6e1b CFRunLoopRunInMode + 123
53  GraphicsServices                    0x04d0e7e3 GSEventRunModal + 88
54  GraphicsServices                    0x04d0e668 GSEventRun + 104
55  UIKit                               0x0272465c UIApplicationMain + 1211
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x00056, 0x000a4>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at TestingFirstProject.Application.Main (string[]) [0x00000] in /Users/rock/Desktop/Sample Project/TestingFirstProject/TestingFirstProject/Main.cs:17
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00049, 0x00077>
60  TestingFirstProject                 0x00009922 mono_jit_runtime_invoke + 722
61  TestingFirstProject                 0x0016c4ae mono_runtime_invoke + 126
62  TestingFirstProject                 0x001706a4 mono_runtime_exec_main + 420
63  TestingFirstProject                 0x00175a95 mono_runtime_run_main + 725
64  TestingFirstProject                 0x00066e05 mono_jit_exec + 149
65  TestingFirstProject                 0x0020433d main + 2013
66  TestingFirstProject                 0x00002955 start + 53

[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSUnknownKeyException Reason: [<SecondViewController 0x12a36ca0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key butnSubmit.
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool_IntPtr (intptr,intptr,intptr,bool,intptr)
  at MonoTouch.UIKit.UIViewController.PresentViewController (MonoTouch.UIKit.UIViewController viewControllerToPresent, Boolean animated, MonoTouch.Foundation.NSAction completionHandler) [0x0006f] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:659 
  at TestingFirstProject.TestingFirstProjectViewController.clickMe (MonoTouch.Foundation.NSObject sender) [0x00006] in /Users/rock/Desktop/Sample Project/TestingFirstProject/TestingFirstProject/TestingFirstProjectViewController.cs:41 
  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 TestingFirstProject.Application.Main (System.String[] args) [0x00000] in /Users/rock/Desktop/Sample Project/TestingFirstProject/TestingFirstProject/Main.cs:17 
Stacktrace:


Native stacktrace:

    0   TestingFirstProject                 0x0009148c mono_handle_native_sigsegv + 284
    1   TestingFirstProject                 0x000d769d sigabrt_signal_handler + 109
    2   libsystem_c.dylib                   0x9a4c386b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   libsystem_sim_c.dylib               0x041e057b abort + 140
    5   TestingFirstProject                 0x001ea3fd monoeg_g_logv + 157
    6   TestingFirstProject                 0x001ea42b monoeg_assertion_message + 43
    7   TestingFirstProject                 0x00215e5f monotouch_unhandled_exception_handler + 159
    8   TestingFirstProject                 0x0008cefc mono_invoke_unhandled_exception_hook + 140
    9   TestingFirstProject                 0x0009100a mono_handle_exception_internal + 4154
    10  TestingFirstProject                 0x0009115f mono_handle_exception + 47
    11  TestingFirstProject                 0x000d42b2 mono_x86_throw_exception + 306
    12  ???                                 0x0b496f8f 0x0 + 189362063
    13  TestingFirstProject                 0x00215f38 monotouch_exception_handler + 136
    14  CoreFoundation                      0x013ca318 __handleUncaughtException + 728
    15  libobjc.A.dylib                     0x0401d0b9 _ZL15_objc_terminatev + 86
    16  libc++abi.dylib                     0x0435ea65 _ZL19safe_handler_callerPFvvE + 13
    17  libc++abi.dylib                     0x0435eacd __cxa_bad_typeid + 0
    18  libc++abi.dylib                     0x0435fbc2 _ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception + 0
    19  libobjc.A.dylib                     0x0401cf89 _ZL26_objc_exception_destructorPv + 0
    20  CoreFoundation                      0x013c9fb1 -[NSException raise] + 17
    21  Foundation                          0x01a08711 -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    22  Foundation                          0x01989ec8 _NSSetUsingKeyValueSetter + 140
    23  Foundation                          0x019899b7 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    24  Foundation                          0x019b4428 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    25  UIKit                               0x029410cc -[UIRuntimeOutletConnection connect] + 106
    26  libobjc.A.dylib                     0x04030663 -[NSObject performSelector:] + 62
    27  CoreFoundation                      0x0133c45a -[NSArray makeObjectsPerformSelector:] + 314
    28  UIKit                               0x0293fbcf -[UINib instantiateWithOwner:options:] + 1327
    29  UIKit                               0x02804e37 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    30  UIKit                               0x02805418 -[UIViewController loadView] + 302
    31  UIKit                               0x02805648 -[UIViewController loadViewIfRequired] + 73
    32  UIKit                               0x02805882 -[UIViewController view] + 33
    33  UIKit                               0x02811235 -[UIViewController shouldAutorotate] + 36
    34  UIKit                               0x02a103d2 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 1933
    35  UIKit                               0x0280e4f3 -[UIViewController presentViewController:withTransition:completion:] + 4521
    36  UIKit                               0x0280e777 -[UIViewController presentViewController:animated:completion:] + 112
    37  ???                                 0x129333bc 0x0 + 311636924
    38  ???                                 0x12933118 0x0 + 311636248
    39  ???                                 0x12932ff5 0x0 + 311635957
    40  ???                                 0x12931ff5 0x0 + 311631861
    41  TestingFirstProject                 0x00009922 mono_jit_runtime_invoke + 722
    42  TestingFirstProject                 0x0016c4ae mono_runtime_invoke + 126
    43  TestingFirstProject                 0x0020f086 monotouch_trampoline + 3686
    44  libobjc.A.dylib                     0x04030705 -[NSObject performSelector:withObject:withObject:] + 77
    45  UIKit                               0x02727920 -[UIApplication sendAction:to:from:forEvent:] + 96
    46  UIKit                               0x027278b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    47  UIKit                               0x027e8671 -[UIControl sendAction:to:forEvent:] + 66
    48  UIKit                               0x027e8bcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
    49  UIKit                               0x027e7d38 -[UIControl touchesEnded:withEvent:] + 546
    50  UIKit                               0x0275733f -[UIWindow _sendTouchesForEvent:] + 846
    51  UIKit                               0x02757552 -[UIWindow sendEvent:] + 273
    52  UIKit                               0x027353aa -[UIApplication sendEvent:] + 436
    53  UIKit                               0x02726cf8 _UIApplicationHandleEvent + 9874
    54  GraphicsServices                    0x04d0fdf9 _PurpleEventCallback + 339
    55  GraphicsServices                    0x04d0fad0 PurpleEventCallback + 46
    56  CoreFoundation                      0x012b6bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    57  CoreFoundation                      0x012b6962 __CFRunLoopDoSource1 + 146
    58  CoreFoundation                      0x012e7bb6 __CFRunLoopRun + 2118
    59  CoreFoundation                      0x012e6f44 CFRunLoopRunSpecific + 276
    60  CoreFoundation                      0x012e6e1b CFRunLoopRunInMode + 123
    61  GraphicsServices                    0x04d0e7e3 GSEventRunModal + 88
    62  GraphicsServices                    0x04d0e668 GSEventRun + 104
    63  UIKit                               0x0272465c UIApplicationMain + 1211
    64  ???                                 0x0e9ccd74 0x0 + 245157236
    65  ???                                 0x0e9cb3e8 0x0 + 245150696
    66  ???                                 0x0e9cabe8 0x0 + 245148648
    67  ???                                 0x0e9cac77 0x0 + 245148791
    68  TestingFirstProject                 0x00009922 mono_jit_runtime_invoke + 722
    69  TestingFirstProject                 0x0016c4ae mono_runtime_invoke + 126
    70  TestingFirstProject                 0x001706a4 mono_runtime_exec_main + 420
    71  TestingFirstProject                 0x00175a95 mono_runtime_run_main + 725
    72  TestingFirstProject                 0x00066e05 mono_jit_exec + 149
    73  TestingFirstProject                 0x0020433d main + 2013
    74  TestingFirstProject                 0x00002955 start + 53

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

最佳答案

异常中的关键信息是:

this class is not key value coding-compliant for the key butnSubmit

这意味着您的 C# 类上有一个属性,但在 .xib(接口(interface)生成器)文件中没有相应的导出。

重新检查/重新创建您的网点,看看是否可以解决问题。

关于iphone - 在单点触控中以模态方式显示 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14801761/

相关文章:

ios - iPhone SDK_表格 View 里面的表格 View

iphone - 如何删除 UIMenuController 中的 COPY UIMenuItem

ios - Swift 3.0 中的结构体枚举

ios - 使用配置文件从终端问题构建 .ipa

android - 为应用程序开发设计 GUI 时,为文本着色的正确方法是什么

c# - 单点触控 : CIContext in FinishedLaunching seems to crash app?

iphone - 我如何检测真实的网络可用性?

iphone - 如何在播放歌曲时在 iOS 中预加载 .mp3?

iphone - 适用于 iPhone 的类似 Web 的选项卡

xamarin.ios - 为什么我升级到最新版本的 MonoDevelop/MonoTouch/XCode 后 mdtool 无法编译?