Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 用触摸键将文本输出到键盘始于Swift_Ios_Uibutton_Keyboard_Swift_Touchesbegan - Fatal编程技术网

Ios 用触摸键将文本输出到键盘始于Swift

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

我正在创建一个用于练习的自定义键盘,我正在尝试使用touchsbegind/Moved/Ended,而不是典型的UIButton控件事件,因为这在我的项目中是必要的。 现在,当我的一个按钮框架包含触摸点时,我试图简单地输出一些文本,如下所示:

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吃掉。希望这能帮助别人

我已经打了一段时间了,似乎触球还没有开始。