我想使用Swift做一個簡單的iOS自定義鍵盤擴展。默認的UIView不符合我的需要,所以我在this上讀到SO問題,我可以使用NSExtensionMainStoryboard
屬性info.plist
中的故事板。iOS自定義鍵盤與故事板
可惜每次我打開我的鍵盤時,我收到以下錯誤
2016-01-18 18:02:56.350 Kappa Keyboard[44790:2959180] Failed to inherit CoreMedia permissions from 44787: (null)
2016-01-18 18:02:56.368 Kappa Keyboard[44790:2959138] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x002f1746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01d32a97 objc_exception_throw + 44
2 CoreFoundation 0x001a6ce1 -[__NSArrayM insertObject:atIndex:] + 881
3 CoreFoundation 0x001a6941 -[__NSArrayM addObject:] + 65
4 UIKit 0x00c7d0bd -[UIViewController _addChildViewController:performHierarchyCheck:notifyWillMove:] + 417
5 UIKit 0x00c968aa -[UIViewController(UIContainerViewControllerProtectedMethods) addChildViewController:] + 78
6 UIKit 0x01206db8 -[_UIViewServiceViewControllerOperator __createViewController:withContextToken:fbsDisplays:appearanceSerializedRepresentations:legacyAppearance:traitCollection:initialInterfaceOrientation:hostAccessibilityServerPort:canShowTextServices:replyHandler:] + 2702
的堆棧跟蹤仍在繼續,但是這是它的要點。
這是我所做的一切(我在一個乾淨的項目中試過)。
- 創建容器應用
- 創建鍵盤目標
- 添加Main.storyboard
- 添加
NSExtension.NSExtensionMainStoryboard: Main
到Info.plist中 - 設置
Main.storyboard
的自定義類的默認KeyboardViewController
任何想法我失蹤?
我很欣賞你徹底,但我在尋找一個基於故事板,鍵盤,而不是一個文件的.xib。 – Harangue