I have a container view, @property (weak, nonatomic) IBOutlet UIView *containerView;
, but it won't move when I set its frame. Here is how I am trying:
- (void)setFramesForCategories
{
CGRect frame = _containerView.frame;
frame.origin.x = 20;
frame.origin.y = self.view.frame.size.height - 52;
frame.size.width = 236;
frame.size.height = 60 * [[_dataDict objectForKey:@"Key"] count];
_containerView.frame = frame;
}
I know this is basic and it has worked for me before, when I was moving programmatically created objects, but it is not working for me now.
The problem I had was the constraints set up in Storyboard were overriding the frame change. This explains why I wasn't having the same issues with programmatically added objects. All I had to do to turn off constraints for the project was to go to the Storyboard.storyboard
file, then make sure the "Utilities" sidebar is open and select the "File Inspector" tab. Then I scrolled down under "Interface Builder Document" and deselected "Use Autolayout." After this, I reran the the project to find setting the frame programmatically did work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With