UITextField 文本意外移动 [英] UITextField text moving unexpectedly

查看:33
本文介绍了UITextField 文本意外移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面演示了当文本字段处于活动状态时文本字段中的文本如何移动.通过对字段应用背景,我发现只有文本移动,而不是整个文本字段本身.上面的文本字段也不会发生这种情况,只有底部的文本字段会发生这种情况

Below is a demonstration of how the text in my text field is moving when the text field is active. By applying a background to the field, i found that only the text moves, not the whole text field itself. This is not happening to the text field above as well, only the bottom one

推荐答案

搜索此问题后,我建议将您的字体更改为另一种字体.但有一些方法可以防止这个问题:

after search for this issue i recommend to change your font to another font. but there is some way to prevent this issue :

你可以使用这个:

 - (void)textFieldDidEndEditing:(UITextField *)textField
{
 [textField layoutIfNeeded]; //Fixes iOS 9 text bounce glitch
  //...other stuff
}

请检查此链接:

编辑后 UITextField 中的文本向上移动(中心编辑时)

UITextField 文本跳转 iOS 9

这篇关于UITextField 文本意外移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆