Ios 用触摸键将文本输出到键盘始于Swift
我正在创建一个用于练习的自定义键盘,我正在尝试使用touchsbegind/Moved/Ended,而不是典型的UIButton控件事件,因为这在我的项目中是必要的。 现在,当我的一个按钮框架包含触摸点时,我试图简单地输出一些文本,如下所示:Ios 用触摸键将文本输出到键盘始于Swift,ios,uibutton,keyboard,swift,touchesbegan,Ios,Uibutton,Keyboard,Swift,Touchesbegan,我正在创建一个用于练习的自定义键盘,我正在尝试使用touchsbegind/Moved/Ended,而不是典型的UIButton控件事件,因为这在我的项目中是必要的。 现在,当我的一个按钮框架包含触摸点时,我试图简单地输出一些文本,如下所示: override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { var touchPoint: UITouch = touches.anyObject() as U
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
var touchPoint: UITouch = touches.anyObject() as UITouch
if CGRectContainsPoint(button01.frame, touchPoint.locationInView(self.view)) {
var output = textDocumentProxy as UITextDocumentProxy
output.insertText(button01.outputText)
}
}
我不明白为什么这样做不起作用,如果有任何帮助,我们将不胜感激。当我将按钮的userInteractionEnabled设置为false时,问题就解决了,这样触摸实际上会被视图注册,而不是被顶部的UIButton吃掉。希望这能帮助别人 我已经打了一段时间了,似乎触球还没有开始。