现在的位置: 首页 > 综合 > 正文

关于图文发表界面textview无法隐藏键盘的解决方案

2018年03月19日 ⁄ 综合 ⁄ 共 725字 ⁄ 字号 评论关闭

关于 图文发表 界面 textview 无法隐藏键盘的解决方案
取消 TextView 中的 auto-enable Return Key  ---- -IssueDailyRecordStoryboard.storyboard
跟scroll view 多少层无关
//点击return 隐藏
issueBlogContent.ShouldChangeText = (text, range, replacementString) =>
{
if (replacementString.Equals("\n"))
{
issueBlogContent.EndEditing(true);
return false;
}
else
{
return true;
}
};
关于点击后台,无法隐藏键盘的原因

需要在textview的上一层容器view重写,项目中是addblog中 --------AddBlog.cs
/// <summary>
/// 点击背景隐藏
/// </summary>
/// <param name="touches">Touches.</param>
/// <param name="evt">Evt.</param>
public override void TouchesBegan (NSSet touches, UIEvent evt)
{
GlobalObject.tempIssue.hidekeyboard ();
base.TouchesBegan (touches, evt);
}
}

全部变量 public static IssueBlogMainViewController tempIssue;

所用方法   public void hidekeyboard()
{
issueBlogContent.ResignFirstResponder ();
}

抱歉!评论已关闭.