search

Home  >  Q&A  >  body text

objective-c - iOS10 textfield 输入中文时文字会下沉

iOS10 UITextField输入中文时文字会下沉,输入英文则是正确的,不会有任何影响。输入完闭丢失焦点后位置回到正确的位置。真机和模拟器效果一样。

字体是14号字,textfield是30的高,应该能容纳下当前的字体

这是我的截图:

以下是我所有的代码:


import UIKit

class ViewController: UIViewController,UITextFieldDelegate{

    @IBOutlet weak var textField: UITextField!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.view.endEditing(true);
    }
}

这是我的storyboard设置截图:

巴扎黑巴扎黑2771 days ago689

reply all(5)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:44:54

    I also encountered this problem. It was fine before iOS10. This problem will occur if the border is set to None for the textfield created with xib. This problem will not occur if the border is set to default. My solution is: set it to have borders by default in xib, and then set it to borderless in code. It's probably a problem with iOS10. Pure code creation is probably no problem either.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:44:54

    Maybe it’s an ios10 bug! I also found out, there is nothing I can do about it.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:44:54

    iOS 10’s own problems, let’s see if there are any fixes in today’s 10.1.

    reply
    0
  • PHPz

    PHPz2017-04-18 09:44:54

    Try using textView

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 09:44:54

    http://stackoverflow.com/ques...

    reply
    0
  • Cancelreply