开发者

Keyboard accessory view hiding text

开发者 https://www.devze.com 2023-04-11 23:55 出处:网络
I have the following problem: I have a standard UITextView which I resize once the keyboard pops up. I al开发者_如何转开发so have another view which I animate into view (not the standard accessory vie

I have the following problem: I have a standard UITextView which I resize once the keyboard pops up. I al开发者_如何转开发so have another view which I animate into view (not the standard accessory view attached to the keyboard). The problem is that I do not want text to be hidden by this view. This is what happens when I reach the last line (orange view = my custom accessory view):

Keyboard accessory view hiding text

Ideally, I'd like to have an automatic scroll should that happen. But I have no clue how to achieve this if I am in the last line of the UITextView. Also, scrollToVisible doesn't work in this context and I don't know if I'd get anywhere with contentInset.

Any suggestions would be welcome! Thanks.

EDIT

I suppose I would need some kind of mechanism which would allow to

  1. make the textview only expand to the line right above the accessory view if I was entering something on the LAST LINE
  2. have the textview expand to the keyboard if I was not editing the LINE DIRECTLY ABOVE the KEYBOARD.

Does that make sense? What I need is the opposite of contentInset, I suppose.

I simply don't want to resize the textView to just above the accessory view as it takes away screen space to display text.


I got the solution- sorry, I guess it was obvious, but it took me the whole day to figure it out:

textOfPage.contentInset = UIEdgeInsetsMake(0, 0, 100, 0);

This will offset my UITextView so that the last line is never hidden. The 100 is in pixels and can be adjusted accordingly.


What I would do is resize the textview in the textViewShouldBeginEditing method to fit above the keyboard and the newly added accessory view, and then resize it back to full screen when the keyboard is dismissed in textViewShouldEndEditing

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号