【发布时间】:2013-03-01 08:23:26
【问题描述】:
我已将 UIViewController 中的 UIScrollView 放入我的情节提要中。当我使用此代码时:
- (void)viewDidLoad
{
[super viewDidLoad];
[_scrollview setContentSize:CGSizeMake(_scrollview.bounds.size.width*2, _scrollview.bounds.size.height)];
[_scrollview setPagingEnabled:YES];
CGRect rect = _scrollview.bounds;
UIView* view = [[UIView alloc]initWithFrame:rect];
[view setBackgroundColor:[UIColor redColor]];
[_scrollview addSubview:view];
rect = CGRectOffset(rect, _scrollview.bounds.size.width, 0);
view = [[UIView alloc]initWithFrame:rect];
view.backgroundColor = [UIColor greenColor];
[_scrollview addSubview:view];
}
没有自动布局也可以正常工作,但是当我启用时,“rect”值等于 0。自动布局的等效代码是什么?
【问题讨论】:
标签: ios6 uiscrollview autolayout