Reputation: 1204
I've got a UITextView that I want to give an inset on the first line. To do so, I insert a couple of spaces at the beginning. However, when the user enters too much text to fit onto one line, the entire text will move to the second line, leaving the entire first line blank.
(screenshots)
The preferred way I'd want this is to only move 'f' to the next line, but probably because of the spaces that account for the first line indent, it recognizes the text after it as a word, and moves the entire thing to the next line.
I tried setting self.textContainer.lineBreakMode = NSLineBreakByCharWrapping;
in the subclass of UITextView
as well as self.passwordTextView.textContainer.lineBreakMode = NSLineBreakByCharWrapping;
in the ViewController, but no luck.
Upvotes: 2
Views: 1282
Reputation: 1204
Problem solved.
Apperently the iOS sdk only responds to NSLineBreakByCharWrapping
when there are not whitespaces inside the string. So instead of adding whitespaces to account for the 'first line indent', I'm now using this in the textViewDidChange:
method:
-(void)textViewDidChange:(UITextView *)textView{
self.passwordTextView.text = [self.passwordTextView.text stringByReplacingOccurrencesOfString:@" " withString:@"\u00A0"];
}
Et voila!
Upvotes: 1