Single line UITextView
The standard behaviour of the UITextView automatically resets the contentInset property to 32, which causes strange behaviour if you just want an UITextView with a single line. On responding the cursor disappears in the negative content area. The solution is simple. Just subclass the UITextView and force overwrite the property contentInset with UIEdgeInsetsZero. It just acts like an UITextField now. The SMS.app for example uses this behaviour for text-input with the ability to enter multiple lines.
@interface InputTextView : UITextView
@end
@implementation InputTextView
/*************************************************
* fixes the issue with single lined uitextview
*************************************************/
- (UIEdgeInsets) contentInset { return UIEdgeInsetsZero; }
@end
Categories: iOS SDK
UITextView single line
This ist correct, but watch out – Apple did this on purpose. If you remove this inset, then the “word-tip” or correction bubble will be cut by the bounds of the UITextview. You can then set clipToBounds=NO, but then you can’t activate the dismiss x anymore…
So you see, there is a whole chain reaction started here