Basically I am trying to create a resizing UITextView within a inputAccessoryView property.
I have a viewController with the method canBecomeFirstResponder returning true and a view I instantiate via a custom class (which gets it from a XIB). Within this view is a UITextView located.
I try to resize the complete inputAccessoryView from inside of that class. I tried in in a few ways: setting the frame directy, try to use a height constraint. It appears it resizes only half way:
This is basically what i want (with or without autolayout, but working in iOS 7/8+):
class MessageInputAccessory: UIView, UITextViewDelegate
{
@IBOutlet weak var textView: UITextView!
func textViewDidChange(textView: UITextView)
{
var contentSize = textView.sizeThatFits(CGSizeMake(textView.frame.size.width, CGFloat.max))
self.frame.size.height = contentSize.height + 20
self.textView.reloadInputViews()
}
}
I have found this post: Changing the frame of an inputAccessoryView in iOS 8. Stating that a automatically created constraint is being created. The thing is, it does not create the constraint for me. In no way, with autolayout disabled or enabled (also via setTranslatesAutoresizingMaskIntoConstraints()).