C# 在Scrollview上开始触摸键盘
UIViewcontroller.View添加了滚动视图 对于scrollview,我添加了文本字段。一行5个文本字段 我想取消键盘textField.ResignFirstResponder;将关闭键盘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
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中。触摸滚动查看其他文本字段,然后关闭键盘。