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];
}
auto-layout がなくても問題なく動作しますが、有効にすると、「rect」値が 0 になります。 auto-layout と同等のコードは何ですか?