ios - UIScrollView scrolling to bottom when UITextField text changes -
as set now, have 2 uitextviews inside of uiscrollview. point of uitextviews don't scroll, larger (their contentsize) more text added. uiscrollview handles of scrolling , down of view regardless of how text there (think similar mail.app subject view above message view, etc). said, i've ran problem now. when programmatically add text uitextview (in code, bodytext), uiscrollview automatically scrolls bottom reason.
to add text do:
nsrange selectedrange = [bodytext selectedrange]; nsstring *selectedtext = [bodytext.text substringwithrange:selectedrange]; bodytext.text = [bodytext.text stringbyreplacingcharactersinrange:selectedrange withstring:[nsstring stringwithformat:@"<b>%@</b>", selectedtext]];
so, instance, if had 2000 pixels vertically of text , scrolled position 400 , added text somewhere around there, uiscrollview go way down 2000.
i've tried stop via subclassing uiscrollview , overriding -setcontentoffset, freezes scrolling then.
my question is, why scroll way bottom in first place? text added when user clicks button somewhere else on screen, , scrolling has nothing finger drags or anything.
in scroll view programming guide get:
making rectangle visible
it possible scroll rectangular area visible. useful when application needs display control outside visible area visible view. scrollrecttovisible:animated: method scrolls specified rectangle visible inside scroll view. if animated parameter yes, rectangle scrolled view @ constant pace. setcontentoffset:animated:, if animation disabled, delegate sent single scrollviewdidscroll: message. if animation enabled, delegate sent series of scrollviewdidscroll: messages animation progresses. in case of scrollrecttovisible:animated: scroll view’s tracking , dragging properties no.
if animation enabled scrollrecttovisible:animated:, delegate receives scrollviewdidendscrollinganimation: message, providing notification scroll view has arrived @ specified location , animation complete.
so maybe can use functionality lock visibility on uitextview.
Comments
Post a Comment