简体   繁体   English

如何在iPhone的键盘内输入文本的UITextview

[英]How to move the UITextview at text enter on inside keyboard in iPhone

I have a UITextView in subview of UIView .I will change the texview height based on the text in the method textViewDidChange . 我有一个UITextView中的子视图UIView 。我将改变基于方法textViewDidChange的文本texview高度。 My thought is when the text view height under goes to inside the keyboard i cant visible the entering text in the textview. 我的想法是当文本视图高度进入键盘内部时,我无法看到textview中输入的文本。 How can solve the issue textview text range over to the keyboard. 如何解决问题textview文本范围到键盘。 How to make the entered text to appear for user. 如何使输入的文本显示给用户。

You can check the size of your text with the font like this: 您可以使用以下字体检查文本的大小:

[@"MYString" sizeWithFont:myFont];

Knowing this, you can compare it with the size of the textview and now when your text is bigger! 知道这一点,你可以将它与textview的大小进行比较,现在你的文字更大!

到达键盘时向上移动文本视图,或者在文本超出最大文本视图大小时降低字体大小。

Take this UITextView in UIScrollView and then set content size with the contentSize of UITextView and scroll the UIScrollView at bottom UIScrollViewUITextView ,然后使用UITextView的contentSize设置内容大小,并在底部滚动UIScrollView

set content size like bellow.. 设置内容大小如下...

float sizescrollview = yourTextView.frame.origin.y + yourTextView.frame.size.height + 20;
scrview.contentSize=CGSizeMake(320, sizescrollview);

and scroll the UIScrollView above of the keyboard like bellow.. 并滚动键盘上方的UIScrollView ,如下所示..

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
scrView.frame = CGRectMake(0, -150, 320, scrView.frame.size.height);
[UIView commitAnimations];

i hope this help you... 我希望这能帮到你......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM