UITextView
iOS 7 で、自動レイアウトを使用して、プログラムで sを作成してきました。次のようなものです。
_textView = [UITextView new];
_textView.translatesAutoresizingMaskIntoConstraints = NO;
_textView.font = [UIFont systemFontOfSize:18.0];
_textView.delegate = self;
[self.view addSubview:_textView];
作成した他の制約に加えて、テキスト ビューの下部に次の制約があります。
_textViewBottomConstraint =
[NSLayoutConstraint constraintWithItem:_textView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.bottomLayoutGuide
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:0.0];
[self.view addConstraint:_textViewBottomConstraint];
キーボードが表示されたときに制約を変更できるように:
- (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];
}
それはすべてうまくいっています...
問題
私は Xcode 6 と iOS 8 に切り替えたばかりです (遅く、私は知っています) UITextView
。例 (テキストビューの背景は黄色):
インセットの原因は何ですか?と に接続されNSTextContainer
ていtextContainerInset
ますか?
- iOS 7以降での作業と
NSTextContainer
正しい使用方法はありますか?textContainerInset
UITextView
- iOS 8でそのようにする必要がありますか?
はいの場合、必要なandUITextView
とともにプログラムで a を作成するためのガイダンスをいただければ幸いです。その後設定。(プログラムで自動レイアウトを使用します)。NSTextContainer
NSLayoutManager
textContainerInset
ありがとう。