Container View made in Storyboard will not change program code

I have a container view, @property (weak, nonatomic) IBOutlet UIView *containerView; but it will not move when I set its frame. This is how I try:

 - (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 that this is basic, and it worked for me before when I moved programmatically created objects, but now it does not work for me.

+4
source share
2 answers

The problem I ran into was that the restrictions set in the Storyboard were overriding the frame change. This explains why I had no problems with programmatically added objects. All I had to do to disable the restrictions for the project was go to the Storyboard.storyboard file, then make sure the Utility sidebar is open and select the File Inspector tab. Then I scrolled down to the "Document Builder Document" and unchecked the "Use Autostart" box. After that, I reprogrammed the project to find that the program code was working programmatically.

+12
source

The "frame" property for presentation is used for the layout. If you have a mockup of your container view in a storyboard and want to move it to code. Try the transform property. For example, self.containerView.transform = CGAffineTransformTranslate (self.containerView.transform, 0.0, 10.0); => move the container view 10 points :)

+3
source

All Articles