Reputation: 3
I am new to Auto Layout in iOS. My application has a Textview
and a Button below the textview
. The application need to update the textview's height and so the button always appear at the bottom of the textview
. The views have enable Auto Layout. In my code, I do:
1.Change the frame of the green textview
self.testView.frame = FRAME(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height + 10);
2.Call the view to update
[self.view invalidateIntrinsicContentSize];
The problem is that the textview
updates its height but it overlaps the button below it. Can anyone help me solve this problem?
Thanks in advance!
Upvotes: 0
Views: 522
Reputation: 12908
Don't do it with code if you are >= iOS 6
. Purely use autolayout. You need to set vertical spacing between textview and button.
This will show a constant space between your textview and button like this:
UPDATE: In your case:
UIButton
's y
axis = UITextView
's height + UIButton
's existing y
+ 10
Upvotes: 1