search

Home  >  Q&A  >  body text

iOS UITextView 光标位置不对

问题

我在tableViewCell中加载了textview控件,但是由于textview的高度被拉伸了,导致textview的起始输入位置不是从左上角开始,而是往下移动了,请问我改如何解决呢?


ringa_leeringa_lee2772 days ago688

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:07:27

    From the picture, I think there is no problem with the input position of textView. This is probably the location. Isn't this the upper left corner?

    You can mark textView red to see the relative position of the cursor and textView. Because UITextViewUILabel is different, it has a little default inset, so it is normal to be slightly downward and to the right.

    Add two sentences

    textView.textContainer.lineFragmentPadding = 0;
    textView.textContainerInset = UIEdgeInsetsZero;

    Can reduce this inset.

    reply
    0
  • Cancelreply