我有一个自定义键盘,我想添加一个XIB文件。但是,每当我尝试加载键盘时,它都会立即崩溃。她是一些代码。
@IBOutlet var mainView:UIView!
override func viewDidLoad() {
super.viewDidLoad()
let xibViews = NSBundle.mainBundle().loadNibNamed("nib",owner: self,options:nil)
self.mainView = xibViews[0] as! UIView
self.view.addSubview(mainView)
for v in self.mainView.subviews as! [UIButton] {
v.addTarget(self, action: "tester", forControlEvents: .TouchUpInside)
}
}
func tester(){
let proxy = textDocumentProxy
proxy.insertText("chi")
}