iOS 8 今日扩展中的 UITableViewController

UITableViewController in iOS 8 Today Extension

我正在尝试将 UITableViewController 添加到今日小工具,但每次我拖动 UITableViewController到 Storyboard 和 运行 Widget 它崩溃并出现以下错误。

我试过很多次了。我已经尝试使用 Table View 对象,但问题仍然存在。

注意:它甚至在加载 viewDidLoad() 方法之前就崩溃了。

2015-06-06 01:19:20.569 iOSHackerToday[3202:283287] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSArrayM insertObject:atIndex:]: object cannot be nil' *** First throw call stack: ( 0 CoreFoundation 0x0000000107842c65 __exceptionPreprocess + 165 1 libobjc.A.dylib
0x00000001074dbbb7 objc_exception_throw + 45 2 CoreFoundation
0x000000010770f8ca -[__NSArrayM insertObject:atIndex:] + 954 3
UIKit 0x0000000107d6f0b9 -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:] + 338 4 UIKit 0x0000000108241a0c -[_UIViewServiceViewControllerOperator __createViewController:withContextToken:fbsDisplays:appearanceSerializedRepresentations:legacyAppearance:traitCollection:initialInterfaceOrientation:hostAccessibilityServerPort:canShowTextServices:replyHandler:] + 2216 5 CoreFoundation 0x0000000107738dec __invoking_
+ 140 6 CoreFoundation 0x0000000107738c42 -[NSInvocation invoke] + 290 7 CoreFoundation
0x00000001077c9016 -[NSInvocation invokeWithTarget:] + 54 8 UIKit
0x00000001082fd01b -[_UIViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 222 9 CoreFoundation
0x000000010779ff4f forwarding + 495 10 CoreFoundation
0x000000010779fcd8 _CF_forwarding_prep_0 + 120 11 CoreFoundation
0x0000000107738dec invoking_ + 140 12 CoreFoundation
0x0000000107738c42 -[NSInvocation invoke] + 290 13 CoreFoundation
0x00000001077c9016 -[NSInvocation invokeWithTarget:] + 54 14 UIKit
0x00000001082889f4 -[_UIQueueingProxy forwardInvocation:] + 319 15 CoreFoundation 0x000000010779ff4f forwarding + 495 16 CoreFoundation 0x000000010779fcd8 _CF_forwarding_prep_0 + 120 17 CoreFoundation
0x0000000107738dec invoking_ + 140 18 CoreFoundation
0x0000000107738c42 -[NSInvocation invoke] + 290 19 CoreFoundation
0x00000001077c9016 -[NSInvocation invokeWithTarget:] + 54 20 CoreFoundation 0x000000010779ff4f forwarding + 495 21 CoreFoundation 0x000000010779fcd8 _CF_forwarding_prep_0 + 120 22 CoreFoundation
0x0000000107738dec invoking_ + 140 23 CoreFoundation
0x0000000107738c42 -[NSInvocation invoke] + 290 24 libdispatch.dylib 0x0000000109da6f16 _dispatch_call_block_and_release + 12 25 libdispatch.dylib 0x0000000109dc1964 _dispatch_client_callout + 8 26 libdispatch.dylib 0x0000000109daca59 _dispatch_main_queue_callback_4CF + 704 27 CoreFoundation 0x00000001077aa1f9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 28 CoreFoundation 0x000000010776bdcb __CFRunLoopRun + 2043 29 CoreFoundation 0x000000010776b366 CFRunLoopRunSpecific + 470 30 GraphicsServices
0x000000010b01ca3e GSEventRunModal + 161 31 UIKit
0x0000000107c3b900 UIApplicationMain + 1282 32 libxpc.dylib
0x000000010a0a7aec _xpc_objc_main + 453 33 libxpc.dylib
0x000000010a0a9e91 xpc_main + 185 34 Foundation
0x0000000107209ee1 service_connection_handler + 0 35 PlugInKit
0x0000000106ff3a82 -[PKService run] + 521 36 PlugInKit
0x0000000106ff3747 +[PKService main] + 55 37 PlugInKit
0x0000000106ff3aa6 +[PKService _defaultRun:arguments:] + 17 38 libextension.dylib 0x000000010978399d NSExtensionMain + 51 39 libdyld.dylib 0x0000000109df1145 start + 1 40 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

删除默认布局并拖动新的table视图控制器时,需要将新视图控制器标记为'Intial View Controller'

这是 Apple 的文档,其中说明了如何操作。 https://developer.apple.com/library/ios/recipes/xcode_help-IB_storyboard/chapters/SetInitialController.html

在情节提要中,如果您使用的是 swift 中制作的自定义视图控制器 class,请务必选中 'Inherit Module From Target':

复选框