そのテキスト フィールドのとして設定されているのUITextField中にある のサイズを変更しようとしましたが、失敗しました。UIViewinputAccessoryView
今、私はサイズ変更を機能させようとしています。ユーザーが 2 行以上のテキストを入力すると、テキストフィールドのサイズが変更され、周囲のビューもサイズ変更されます ( inputAccessoryView)。
私の中に次のコードがありますUITextFieldDelegate:
func textViewDidChange(textView: UITextView) {
println("textViewDidChange called")
sendButton.enabled = textView.hasText()
var oldHeight = textView.frame.height
var textWidth = textView.frame.width
textView.sizeToFit()
var textFrame = textView.frame
textFrame.size.height = textView.contentSize.height
textFrame.size.width = textWidth
textView.frame = textFrame
var newHeight = textView.frame.height
moveToolbarUp(newHeight - oldHeight)
self.frame.size.height += newHeight - oldHeight
self.superview?.updateConstraints()
}
テキストフィールドに入力しすぎると、これが発生します。これが起こらないようにするにはどうすればよいですか? また、inputAccessoryViewリターンキーを押すと完全にリセットされます。で別の方法を使用する必要がありdelegateますか? これらの高さを自分で計算するべきではありませんか? inputAccessoryView私のテキストビューだけが適切にサイズ変更されないのはなぜですか?