2
我已將UIScrollView放入我的故事板中的UIViewController中。當我使用此代碼:我的UIScrollView無法在ios6中自動佈局
- (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];
}
它的正常工作沒有自動佈局,但是當我使,「矩形」值是等於0。什麼是自動佈局的等同的代碼?