I created a UITextView programmatically using an automatic layout in iOS 7. Something like this:
_textView = [UITextView new]; _textView.translatesAutoresizingMaskIntoConstraints = NO; _textView.font = [UIFont systemFontOfSize:18.0]; _textView.delegate = self; [self.view addSubview:_textView];
In addition to the other restrictions I created, I have this for the bottom of the text view:
_textViewBottomConstraint = [NSLayoutConstraint constraintWithItem:_textView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0]; [self.view addConstraint:_textViewBottomConstraint];
So I can change the restriction when the keyboard displays:
- (void)keyboardDidShow:(NSNotification*)sender { CGRect keyboardFrame = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; CGRect convertedFrame = [self.view convertRect:keyboardFrame fromView:self.view.window]; _textViewBottomConstraint.constant = -convertedFrame.size.height; [_textView layoutIfNeeded]; }
So that everything works fine ...
Problem
I just switched to Xcode 6 and iOS 8 (late, I know) - and the text in the UITextView now has an insert at the top. For example. (Background of the text image is yellow):

What causes the insert? Is it NSTextContainer to NSTextContainer and textContainerInset ?
- Works with
NSTextContainer and textContainerInset correct way to use UITextView from iOS 7 onwards - Does it have to do this in iOS 8?
If so, I would appreciate some recommendations for programmatically creating a UITextView along with the necessary NSTextContainer and NSLayoutManager ; then set textContainerInset . (I will use automatic linking, programmatically).
Thanks.
ios7 ios8 uitextview nslayoutmanager nstextcontainer
Gavin hop
source share