ios - 初始化程序不会覆盖指定的初始化程序 Swift WatchKit

标签 ios swift watchkit

我刚刚更新了 Xcode 的新测试版以继续开发我的 WatchKit 应用

更新我的所有 WatchKit 扩展文件后我立即收到错误

“初始化器不会覆盖其父类(super class)中的指定初始化器”

我在更新之前没有收到此错误,不确定如何解决。

有什么见解吗?

这是我的代码

class InterfaceController: WKInterfaceController {

override init(context: AnyObject?) {
    // Initialize variables here.
    super.init(context: context)

    // Configure interface objects here.
    NSLog("%@ init", self)
}

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
    NSLog("%@ will activate", self)
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    NSLog("%@ did deactivate", self)
    super.didDeactivate()
}

}

最佳答案

随着 Beta 3 的发布,initWithContext 现在已被弃用。您应该使用 awakeWithContext。 WKInterfaceController 类的 init 方法现在指定为初始化程序。

引用: https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-8.2/index.html注释部分。

关于ios - 初始化程序不会覆盖指定的初始化程序 Swift WatchKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27672222/

相关文章:

ios - 为什么我在 iOS 设备测试中得到 "Building MacinTalk voice for asset: (null)"

ios - 捕获崩溃日志并将其发送到服务器

iphone - 是否有可能为 UILocalNotification 设置条件 `firedate`?

ios - JSON解码到字典

ios - FBSOpenApplicationErrorDomain 代码=3

ios - watch 动画

ios - 如何在 iOS 的 TabView 应用程序中将数组从一个 TableView 传递到另一个?

ios - 使用 PromiseKit 处理错误

ios - 将 XML 字符串中的 html 标签替换为 null

ios - iOS WatchKit 中的固定大小表格