首页 > 解决方案 > 初始化程序的问题:在 super.init 调用时未初始化属性“self.options”

问题描述

我正在使用来自 cocoapods 的SwiftPageMenu 。它曾经完美地工作。但是在我通过 pod 重新安装它之后,我不断收到这个错误

线程 1:致命错误:init(coder:) 尚未实现

我寻找了一些解决方案,主要建议改变:

required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

至 :

  required init?(coder aDecoder: NSCoder) {
   super.init(coder: aDecoder)
}

但我明白了

属性“self.options”未在 super.init 调用中初始化

options 在其他 init 函数中初始化:

   public init(options: PageMenuOptions? = nil) {
        self.options = options ?? DefaultPageMenuOption()
        super.init(nibName: nil, bundle: nil)
    }




    public init?(coder: NSCoder, options: PageMenuOptions? = nil) {
        self.options = options ?? DefaultPageMenuOption()
        super.init(coder: coder)
    }

我真的不明白这个问题有人可以帮助我吗?

这是控制器

标签: swiftcocoapodsinitializer

解决方案


推荐阅读