1
votes

I have a subview inside a view with constraints top,left,bottom,right,width and height. I also have IBOutlet for height constraint. I want to change height constraint programmatically so it grows and push parent views. Problem is when I change constraint's constant it pushes parent view but not expand itself. But if i do it in ui editor it works fine.

White one is subview which i want to expand white one is subview which i want to expand

Constraints are here

constraints are here

Before constraints setenter image description here

After constraints set with;

self.heightConst.constant = 300;

enter image description here

1
Validate IBOutlet, your bind not right.Bimawa
I checked, it looks like correct.Fatih Donmez
You have added bottom constraints for your subview then how can you change the height constraints?Raj Subbiah
then how would it pushed parent view to expand?Fatih Donmez
can you share simple project for look it?Bimawa

1 Answers

0
votes

Base on your 2nd screenshot, you haven't assign your property (heightConst) to your Interface Builder (.xib or .storyboard)

and make sure your property has IBOutlet. @property (nonatomic,weak) IBOutlet NSLayoutConstraint*heightConst;