Search This Blog

Tuesday, 11 March 2014

UITextView issue -iOS

Hello Friends,

                So here is another thing coming in iOS7 which may annoy you some day today or later....in iOS7 , if you guys noted or not your UITextView clips last line out of view. Try this thing tap on return until you reach end of UITextView bounds now again tap return and start typing ....voila where is the text !!!

             Actually it gets clipped , i am not sure if it is a bug or apple did this intentionally. But, the bottom line is  " It's Annoying" . Yesterday i wasted 2 hours to solve this issue :P

           And here is the code which may handle this thing at some extent.

NOTE: This code will clip the last line on tapping return , but as soon as user starts typing characters the line becomes visible :)


STEP 1: I assume you are using UITextViewDelegate in your view controller.

STEP 2: Simply over ride this below delegate function in your view controller.


-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
   
   [textView scrollRangeToVisible:range];
    return YES;
}


I am simply trying to autoscroll the textview to make the range visible. I think its the easiest way to cope with it , until apple sort out this thing :)


Happy Programming!
CHAO

No comments:

Post a Comment