Just wanna ask if there are any possibilities to add a '\n' character to the end of the line when a word wraps in a UITextView?
I am sure that RETURN ('\n') is not going to impact me on this.
--Edit--
Enter some text in UITextView. When the text view is resigning its first responder, append '\n' characters to the end of every line (the line in text view where the word wrapped) and obtain the complete content as a string.
Thanks in advance.
__________________ U can not fail,until U Quit...
Manoj B
Last edited by manojb; 02-10-2012 at 03:30 AM.
Reason: -- bump --
Just wanna ask if there are any possibilities to add a '\n' character to the end of the line when a word wraps in a UITextView?
I am sure that RETURN ('\n') is not going to impact me on this.
Thanks in advance.
I got to this much (see code). Can someone suggest me what to proceed further ?
Code:
// create the complete range of the text content
NSRange textRange = NSMakeRange(0, [textView text].length);
NSRange delimiter;
// every word's length variable
NSInteger wordsLength = 0;
for (wordsLength = textRange.location; wordsLength <= [textView text].length; wordsLength = delimiter.location)
{
NSLog(@"WordsLength - %d, maxLimit - %f, textRange - %@", wordsLength, maxLimit, NSStringFromRange(textRange));
// Check if a character is right after the cursor
unichar c = ' '; // uni-codes as 32 - blank space
if(wordsLength != [textView.text length])
{
// get the character at the position
c = [textView.text characterAtIndex:textRange.location];
}
// If not a character, then cursor move to the end of a word
if(c != 32 && c != 10)
{
delimiter = [textView.text rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet] options:NSLiteralSearch
range:NSMakeRange(textRange.location, [textView.text length] - textRange.location)];
if(delimiter.location == NSNotFound)
{
delimiter.location = [textView.text length];
}
}
else if (c == 32) // for blank space character add 1 to the delimiter
{
delimiter.location += 1;
}
textRange = delimiter;
}
I am trying to find at which character, the line ends (with a word wrap).
Just wanna ask if there are any possibilities to add a '\n' character to the end of the line when a word wraps in a UITextView?
I am sure that RETURN ('\n') is not going to impact me on this.
--Edit--
Enter some text in UITextView. When the text view is resigning its first responder, append '\n' characters to the end of every line (the line in text view where the word wrapped) and obtain the complete content as a string.