问题描述
我已经在情节板上放了一个卷轴.
接下来,在我调用的代码中
self.scroll.frame = CGRectMake(100, 0, 800, 900);
我想滚动应将位置更改为(100,0)
,但不知何故它仍然处于故事板中设置的原始位置.
我缺少什么?
推荐答案
是的
如果要在代码中设置框架初始化.
@property (nonatomic,strong) UIScrollView *scrollView; _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
如果要在Autolayout系统中设置位置,则应考虑更新视图的约束.
self.scrollViewWidthConstraint.constant += 20; [self.scrollView updateConstraints];
问题描述
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 ?
推荐答案
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];
相关问答
iOS:UISCrollView Zooming从编程上不起作用
.on(" click")对iOS不起作用
UIScrollView的内容嵌套对键盘高度不起作用
视频对Safari和iOS不起作用
UITapGestureRecognizer对UIScrollView的子视图中的UILabels不起作用
为什么NSWINDOW ANIMATOR SETFRAME:显示:动画:有时不起作用?
UISCROLLVIEW设置contentOffset in ViewWillAppear不起作用
iOS 5-CTCallCenter对我不起作用
iOS中的单词词干-对单个单词不起作用
scrollViewWillEndDragging:withVelocity:targetContentOffset:在UISCrollView的边缘不起作用。
相关标签/搜索