我试图以这种方式将CLFormRowDescriptor
连接到视图控制器:
var form = XLFormDescriptor()
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "ABC") as XLFormDescriptor
section = XLFormSectionDescriptor.formSectionWithTitle("Bla bla") as XLFormSectionDescriptor
form.addFormSection(section)
row = XLFormRowDescriptor(tag: "bla", rowType: XLFormRowDescriptorTypeSelectorPush, title: "BlaBla");
row.action.viewControllerStoryboardId = "test";
section.addFormRow(row)
视图控制器Storyboard ID为test
。
当我运行该应用程序时,我收到以下错误消息:
2015-07-03 16:42:24.022 TestTest [1001:203160] ***
在声明失败 - [XLFormSelectorCell formDescriptorCellDidSelectedWithFormController:],/Users/valec/Developer/TestTest/ios/Pods/XLForm/XLForm/XL/Cell/XLFormSelectorCell.m:166
2015-07-03 16:42:24.024 TestTest [1001:203160] ***
由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'rowDescriptor.action.viewControllerClass必须符合XLFormRowDescriptorViewController协议' ***首先抛出调用堆栈:
(0x18246c2d8 0x1941400e4 0x18246c198 0x183320ed4 0x100387a5c 0x100398680 0x10039c6d0 0x18700d408 0x1870c7724 0x186f681d4 0x186ed8680 0x1824242a4 0x182421230 0x182421610 0x18234d2d4 0x18bda36fc 0x186f4af40 0x100028e8c 0x1947eaa08) libc ++ abi.dylib:以NSException类型的未捕获异常终止
您对如何解决此问题有所了解吗?您还需要更多代码或信息吗?
答案 0 :(得分:0)
由于您的行类型为07-06 22:23:37.574 24510-24510/com.prashanth.emergencycontacts I/Timeline﹕ Timeline: Activity_launch_request id:com.prashanth.emergencycontacts time:14497951
07-06 22:23:37.601 24510-24510/com.prashanth.emergencycontacts I/ViewRootImpl﹕ CPU Rendering VSync enable = true
07-06 22:23:37.637 24510-24510/com.prashanth.emergencycontacts I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@2f428e3d time:14498015
07-06 22:23:37.662 24510-24528/com.prashanth.emergencycontacts D/OpenGLRenderer﹕ endAllStagingAnimators on 0xa18af280 (ListView) with handle 0xaec2ce40
07-06 22:23:38.413 24510-24510/com.prashanth.emergencycontacts I/Timeline﹕ Timeline: Activity_launch_request id:com.prashanth.emergencycontacts time:14498790
07-06 22:23:38.472 24510-24510/com.prashanth.emergencycontacts D/AndroidRuntime﹕ Shutting down VM
07-06 22:23:38.473 24510-24510/com.prashanth.emergencycontacts E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.prashanth.emergencycontacts, PID: 24510
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.prashanth.emergencycontacts/com.prashanth.emergencycontacts.Contacts}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setText(java.lang.CharSequence)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2354)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5287)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setText(java.lang.CharSequence)' on a null object reference
at com.prashanth.emergencycontacts.Contacts.onCreate(Contacts.java:65)
at android.app.Activity.performCreate(Activity.java:6041)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5287)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
,因此XLForm会推断您要实现自定义选择器并尝试将行描述符(包含当前选定值)传递给选择器视图控制器(在您的情况下为视图控制器)其中"测试"作为故事板ID)。
制作"测试"视图控制器符合XLFormRowDescriptorTypeSelectorPush
以解决您的问题。