问题
I've put a ScrollView in storyboard.
Next, in the code I call
self.scroll.frame = CGRectMake(100, 0, 800, 900);
I suppose the scroll should change the position into (100, 0)
But somehow it still remains in the original position where was set in storyboard.
What am I missing ?
回答1:
Yes it won't work for any view in autolayout system at all if added using storyboard or xib.
If you want to set frame initialise in your code.
@property (nonatomic,strong) UIScrollView *scrollView;
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
If you want to set position in autolayout system you should consider updating the constraints of the view.
self.scrollViewWidthConstraint.constant += 20;
[self.scrollView updateConstraints];
来源:https://stackoverflow.com/questions/32198375/setframe-doesnt-work-for-uiscrollview-in-ios