UIView instanceFromNib函数

问题描述

我正在尝试展示我在xib文件中内置的自定义键盘,当我实例化该类时,我需要将一些变量传递给该类,以使事情正常运行,但是却出现了此错误: Instance member 'target' cannot be used on type 'CustomKeyboardView'

在线

 self.target = target
 self.section = section


class CustomKeyboardView: UIView {
    
    weak var target:UIKeyInput?
    var section:Int?
    
    class func instanceFromNib(target: UIKeyInput,section: Int) -> UIView {
        self.target = target
        self.section = section
        return UINib(nibName: "CustomKeyboard",bundle: nil).instantiate(withOwner: nil,options: nil)[0] as! UIView
    }
}

如何解决此问题或以其他方式将信息传递给班级?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)