UITextView does not resize in UIView

I have UIView

one that has three subheadings, two buttons, and one text view. One button is constrained to the left and bottom UIView

, and the other is constrained to the right and bottom. The text view is bounded at the top and bottom UIView

, as well as two buttons.

I am resizing UIView

when the text view resizes. I am executing logic in a textViewDidChange

function

func textViewDidChange(textView: UITextView) {
    var messageViewHeight = messageView.frame.height
    var messageY = messageView.frame.origin.y
    // Resize the message view if text view has multiple lines
    if (textView.contentSize.height > messageViewHeight) {
        messageViewHeight += origHeight
        messageY -= origHeight
    }
    // Set the message view frame
    messageView.frame = CGRect(x: 0, y: messageY, width: messageView.frame.size.width, height: messageViewHeight)
}

      

Where origHeight

is the original height UITextView

and messageView

is the parent UIView

.

UIView

gets the correct resize, but the problem is that the text view doesn't change. I don't have enough reputation to show images yet to show a screenshot.

It seems that all the sub-items are no longer limited at the bottom UIView

. Do I need to add constraints again? Or is there a better way to resize UIView

?

+3
ios swift uiview uitextview


source to share


No one has answered this question yet

Check out similar questions:

2123
Vertically align text to the top in a UILabel
705
Placeholder in UITextView
559
Providing rounded corners to UIView
458
UIScrollView Scrollable Content Size Ambiguity
1
How to rotate a UITextView without resizing?
1
How to change the height of a UIView based on the elements inside it
0
Strange thing happens when resizing UITextView in UITableViewCell
0
How to change UIView Y axis dynamically based on the size of the UITextView content
0
How to make UIView expand to contain UIImageView or UITextView with auto layout and IB?
0
Wrapping UITextView inside UIView



All Articles
Loading...
X
Show
Funny
Dev
Pics