有没有人知道在没有模板附带的MainInterface.storyboard
的情况下编写iOS 8共享扩展程序的好方法?
当我删除文件或从NSExtensionMainStoryboard
删除Info.plist
时,扩展程序停止工作(当您点击共享窗格中的按钮时没有任何反应)。我们尝试将NSExtensionMainStoryboard
替换为NSExtensionPrincipalClass
,这也无效。
有什么想法吗?
答案 0 :(得分:46)
想出来了!
原来在Swift中发生了一个奇怪的模块命名事件,所以你可以通过在类中添加@objc
名称来修复它:
@objc(PrincipalClassName)
class PrincipalClassName: UIViewController {
...
然后将NSExtensionPrincipalClass
密钥设置为PrincipalClassName
。
答案 1 :(得分:11)
对于Objective-C,您必须将以下内容放在App扩展的info.plist
中:
NSExtensionPrincipalClass
并确保它位于NSExtension
Dict
所以完整答案应该是这样的,在我的情况下ActionViewController
是App扩展名viewController
答案 2 :(得分:3)
无法添加评论但不再是 NSPrincipalClass ,而是 NSExtensionPrincipalClass
答案 3 :(得分:1)
代替[(486, -0.20494145154953003),
(458, -0.20494145154953003),
(503, -0.20494145154953003),
(1732, -0.17177608609199524),
(4432, -0.1629350632429123),
(4714, -0.1629350632429123),
(4537, 0.16059553623199463),
(1103, -0.15242460370063782),
(1014, -0.1514768898487091),
(8915, 0.15007290244102478),
(8901, 0.15007290244102478),
(5387, 0.14965689182281494),
(6508, -0.14788493514060974),
(1765, -0.14788493514060974),
(1744, -0.14788493514060974),
(3650, 0.14648930728435516),
(1120, 0.14613059163093567),
(6345, -0.14582915604114532),
(2234, -0.14568257331848145),
(5361, 0.14548826217651367),
(2558, 0.1453399807214737),
(4711, -0.1450151801109314),
(4445, -0.1450151801109314),
(8870, 0.14448410272598267),
(8862, 0.14448410272598267),
(8851, -0.14395320415496826),
(8824, -0.14391806721687317),
(9351, -0.1435808539390564),
(4078, 0.14126691222190857),
(8006, 0.14126691222190857),
(8324, -0.14036694169044495),
(4186, 0.14015284180641174),
(4934, 0.14015284180641174),
(3941, -0.1399686485528946),
(3929, -0.1399686485528946),
(5173, -0.13947832584381104),
(3774, -0.13858705759048462),
(4410, -0.13752153515815735),
(4442, -0.13752153515815735),
(4705, -0.13752153515815735)]
hack,在Swift中完成此操作的正确方法是在@objc
中包含模块名称,即
NSExtensionPrincipalClass
(否则记录错误:
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ActionViewController</string>
希望将来能帮助遇到此错误的人。