textview.selectedRange.location in UITextview show 2147483647

Posted by Risma on Stack Overflow See other posts from Stack Overflow or by Risma
Published on 2011-01-05T03:49:19Z Indexed on 2011/01/05 3:53 UTC
Read the original article Hit count: 188

Filed under:
|
|
|

hi

i have a textview and i want to get the selectedRange.location value from that textview. in the first time when the keyboard appear, the location value always show an integer point such as 110, or others. But if i dissappear the keyboard and then appear the keyboard again, the location value always show 2147483647. What is this 2147483647 mean and how to get the real location value?

This is my code in the keyboard will appear method :

    -(void)keyboardWillAppear:(NSNotification *)notification {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:[[[notification userInfo] 
                               objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; 
CGRect keyboardEndingUncorrectedFrame = [[[notification userInfo] 
                                          objectForKey:UIKeyboardFrameEndUserInfoKey ] CGRectValue];
CGRect keyboardEndingFrame = 
[self.view convertRect:keyboardEndingUncorrectedFrame 
              fromView:nil];

[UIView commitAnimations];
NSRange selectedRange = textview.selectedRange; 
NSLog(@"selected Range location : %f", selectedRange.location);

}

© Stack Overflow or respective owner

Related posts about ipad

Related posts about keyboard