编写没有故事板的iOS 8共享扩展 [英] Writing an iOS 8 share extension without a storyboard

查看:137
本文介绍了编写没有故事板的iOS 8共享扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道在没有模板附带的 MainInterface.storyboard 的情况下编写iOS 8共享扩展的好方法?

Does anyone know of a good way to write an iOS 8 share extension without the MainInterface.storyboard that comes with the template?

当我从 Info.plist 中删除​​文件或删除 NSExtensionMainStoryboard 时,扩展程序停止工作(点击共享窗格中的按钮时没有任何反应)。我们尝试用 NSExtensionPrincipalClass 替换 NSExtensionMainStoryboard ,这也无效。

When I delete the file or remove the NSExtensionMainStoryboard from Info.plist, the extension stops working (nothing happens when you tap on the button in the share pane). We tried replacing NSExtensionMainStoryboard with NSExtensionPrincipalClass which also didn't work.

任何想法?

推荐答案

想出来!

原来在Swift中有一个奇怪的模块命名事件,所以你可以通过在类中添加一个 @objc 来修复它:

Turns out there's a weird module naming thing going on in Swift, so you can fix it by adding an @objc name to the class:

@objc(PrincipalClassName)

class PrincipalClassName: UIViewController {
...

然后将 NSExtensionPrincipalClass 键设置为 PrincipalClassName

这篇关于编写没有故事板的iOS 8共享扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆