ios - Strange Behavior in Scrolling UIScrollView to UITextView hidden by keyboard -
i have looked @ number of posts here on scrolling , unhiding uitextfield , believed same code should work uitextview, seems not case. first issue encountered sample app have ipad app supporting landscape orientation only. keyboard size returned notification had height , width of keyboard reversed.
next, while can scrollview scroll textview, not reveal of , in fact amount of textview shown dependent on tap in textview. more scrolling cursor not want.
here code using. taken example, real change uitextview used instead of uitextfield. if thing replace textview textfield works fine.
- (void)keyboardwasshown:(nsnotification*)anotification { nsdictionary* info = [anotification userinfo]; cgsize kbsize = [[info objectforkey:uikeyboardframebeginuserinfokey] cgrectvalue].size; uiedgeinsets contentinsets = uiedgeinsetsmake(0.0, 0.0, kbsize.width, 0.0); _myscrollview.contentinset = contentinsets; _myscrollview.scrollindicatorinsets = contentinsets; cgrect arect = self.view.frame; arect.size.height -= kbsize.width; debuglog(@"textview = %@", _textview); if (!cgrectcontainspoint(arect, _textview.frame.origin) ) { cgpoint scrollpoint = cgpointmake(0.0, _textview.frame.origin.y-kbsize.width); [_myscrollview setcontentoffset:scrollpoint animated:yes]; } }
if wanting scroll top of uitextview can by
[textview scrollrecttovisible:cgrectmake(0,0,1,1) animated:yes];
try messing below method. perhaps set height of textview. can post screenshot of issue?
- (void)textviewdidchangeselection:(uitextview *)textview { [textview setselectedrange:nsmakerange(0, 0)]; }
Comments
Post a Comment