Swift必须调用超类uiinputviewcontroller的指定初始值设定项 [英] Swift Must call a designated initializer of the superclass uiinputviewcontroller

查看:1332
本文介绍了Swift必须调用超类uiinputviewcontroller的指定初始值设定项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天上午升级到8.3后,我在主题中收到错误。

I get the error in the subject after this morning's upgrade to 8.3.

以下代码用于完美运行,但不再编译。你们有没有人可以帮助我?

The code below used to work perfectly, however it doesn't compile anymore. Can any of you please help me?

protocol CustomAccessoryProtocol {
    func controlButtonPressed(tag:Int)
}

class CustomAccessory : UIInputViewController {
    var accessoryView : UIView!
    var delegate : CustomAccessoryProtocol!

    @IBOutlet weak var returnButton: UIButton!
    @IBOutlet weak var backButton: UIButton!
    @IBOutlet weak var forwardButton: UIButton!

    init(delegate: CustomAccessoryProtocol){
        super.init()
        self.delegate = delegate
    }

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

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        let customNib = UINib(nibName: "CustomAccessory", bundle: nil)
        accessoryView = customNib.instantiateWithOwner(self, options: nil)[0] as! UIView
    }

    @IBAction func buttonPress(sender: AnyObject) {
        delegate.controlButtonPressed(sender.tag!)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(accessoryView)
    }
}


推荐答案

我在下面的代码中遇到了与NSWindowController相同的问题:

I had the same problem on the following code with NSWindowController:

init() {
    super.init()
}

我将其更改为:

convenience init() {
    self.init()
}

我认为Apple比以前更严格地执行便利性。

I'm thinking that Apple is enforcing convenience inits more strictly than before.

这篇关于Swift必须调用超类uiinputviewcontroller的指定初始值设定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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