iOS 8 Beta Today扩展小部件未在Swift应用中显示? [英] iOS 8 Beta Today extension widget not showing in a Swift app?
问题描述
今天的扩展程序没有出现在Swift应用程序中,但它在Objective C应用程序中出现。
我所做的是在故事板上为快速和客观的c应用添加一些UILabel和一些内容。
<当我运行Objective C应用程序时,它出现了,但是当我执行Swift应用程序时却没有。
我在这里遗漏了什么吗?
你可以注释掉提供的init方法。
// init(nibName nibNameOrNil:String?,bundle nibBundleOrNil:NSBundle?){
// super.init(nibName:nibNameOrNil,bundle:nibBundleOrNil)
// / /自定义初始化
//}
这将使您的分机正常运行。这个问题似乎是由Swift和Objective-C之间不同的初始化程序行为引起的。删除上面的初始化程序将从超类继承所有必需的初始化程序。
找到该解决方案供您参考。
注意:您可能必须清理并构建
之后,在更改生效之前执行此项目
扩展实际上是崩溃,错误如下:
致命错误:使用未实现的初始化程序'init(coder :)' for class'com_blabla_blabla_MyTodayExtension.TodayViewController'
这表示另一个选项是实现:
init(coder aDecoder:NSCoder!){
super.init(coder:aDecoder)
//自定义初始化
}
如果你想保留t的能力o进行自定义初始化。
Today extension doesn't show up in a Swift app, but it does in a Objective C app.
What I did was to add a UILabel with some content on the storyboard for the swift and objective c apps.
It showed up when I ran the Objective C app, but not when I executed the Swift app.
Am I missing something here?
You can comment out the supplied init method.
// init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
// super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// // Custom initialization
// }
This will allow your extension to run properly. The issue seems to be caused by differing initializer behavior between Swift and Objective-C. Removing the above initializer will inherit all of the required initializers from the superclass.
Found that solution on the apple developer forums for your reference.
Note: You may have to Clean and Build
your project after doing this before the changes will have any effect
The extension is actually crashing, with an error like:
fatal error: use of unimplemented initializer 'init(coder:)' for class 'com_blabla_blabla_MyTodayExtension.TodayViewController'
This indicates that another option would be to implement:
init(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
// Custom initialization here
}
if you want to retain the ability to do custom initialization.
这篇关于iOS 8 Beta Today扩展小部件未在Swift应用中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!