将TextField inputView设置为xib视图

问题描述

我正在尝试在xib文件中构建键盘,然后将我的textField的inputView设置为该文件,但是它返回了我为xib文件创建的UIView文件,如何显示xib文件?仅显示代码中的按钮(因为我不知道如何显示xib视图)

cell.repsInput.inputView = CustomKeyboardView(frame: CGRect(x: 0,y: 0,width: self.view.frame.width,height: 300),target: cell.repsInput)


class CustomKeyboardView: UIView {
    
    weak var target:UIKeyInput?

    init(frame: CGRect,target: UIKeyInput) {
        super.init(frame: frame)
        self.target = target
        
        let button = UIButton(frame: CGRect(x: 0,width: 50,height: 50))
        button.setTitle("a good button",for: .normal)
        button.addTarget(self,action: #selector(buttonpressed),for: .touchUpInside)
        self.addSubview(button)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func buttonpressed(){
        target?.insertText("12")
    }
    

}

[![我想显示为文本框的输入视图] [1]] [1]

我想在单击textField时显示什么 [1]:https://i.stack.imgur.com/W1kG6.png

解决方法

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

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

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