开发者

How to scroll textview horizontally while entering text?

I have an application in which i have a scroll view and i have add textview in scrollview. I have set frame of textview (0,0,560,200) as i want textview width more then Iphone screen width.

Now my question is how to scroll my textview in left direction with entering text in textview at end of screen width?

That means when i reach to end of screen width by entering text, the textview should scroll in left a开发者_如何学Pythons i continue to entering text.


This will give the width of text entered

CGSize textSize = [yourTextview.text sizeWithFont:yourTextview.font constrainedToSize:yourTextview.contentSize lineBreakMode:UILineBreakModeWordWrap]; CGFloat ff=textSize.width;


You need not use scrollview as UITextView will have scroll properties.You can make use of notification which you get while entering text.i,e "UITextViewTextDidChangeNotification" and change textview contentoffset as you want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜