Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.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
C# 在Scrollview上开始触摸键盘_C#_Ios_Touch_Xamarin_Uigesturerecognizer - Fatal编程技术网

C# 在Scrollview上开始触摸键盘

C# 在Scrollview上开始触摸键盘,c#,ios,touch,xamarin,uigesturerecognizer,C#,Ios,Touch,Xamarin,Uigesturerecognizer,UIViewcontroller.View添加了滚动视图 对于scrollview,我添加了文本字段。一行5个文本字段 我想取消键盘textField.ResignFirstResponder;将关闭键盘 public override void TouchesBegan (NSSet touches, UIEvent evt) { base.TouchesBegan (touches, evt); UITouch touch = touches.AnyO

UIViewcontroller.View添加了滚动视图

对于scrollview,我添加了文本字段。一行5个文本字段

我想取消键盘textField.ResignFirstResponder;将关闭键盘

public override void TouchesBegan (NSSet touches, UIEvent evt)
    {
        base.TouchesBegan (touches, evt);
        UITouch touch = touches.AnyObject as UITouch;


        if (touch.LocationInView (scroll_View))
        {
            // the touch event happened inside the UIView imgTouchMe.
            textField.ResignFirstResponder ();              
        }
    }
由于其scrollView已添加到view controller view.AddSubView Scroll_view

所以,我用touchesbeated来打发键盘

public override void TouchesBegan (NSSet touches, UIEvent evt)
    {
        base.TouchesBegan (touches, evt);
        UITouch touch = touches.AnyObject as UITouch;


        if (touch.LocationInView (scroll_View))
        {
            // the touch event happened inside the UIView imgTouchMe.
            textField.ResignFirstResponder ();              
        }
    }
它显示了一个错误:

无法隐式地将类型MonoTouch.UIKit.UITouch“转换为System.Drawing.Point”CS0029 IOS

有什么办法我可以不用键盘吗

@全部 提前谢谢

public override void TouchesBegan (NSSet touches, UIEvent evt)
{
    base.TouchesBegan (touches, evt);
    this.View.EndEditing (true);
}

简单的方法,试试看

LocationInView返回一个点。你在if声明中将它与什么进行比较?你能解释一下你希望键盘在哪里以及可能如何退出吗?不清楚。@latenitecoder在滚动视图中我添加了5个文本字段,滚动视图被添加到uiviewcontroller.view中。触摸滚动查看其他文本字段,然后关闭键盘。