가로로 스크롤하는 여러보기를 하나의보기에 만듭니다. 다음 코드는 잘 작동 :UIScrollview는 iOS 스크롤하지 않습니다
-(void)updateSection {
builder = [NSMutableArray array];
float xPosition = 0;
float xposbut = 100;
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 100, self.frame.size.width, self.frame.size.height - 69)];
scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
scrollView.delegate = self;
[self addSubview:scrollView];
for (int i = 1; i < itemArticleArray.count; i++) {
ItemView *item = [ItemView loadNibs];
item.frame = CGRectMake(xposbut, 10, item.frame.size.width, item.frame.size.height);
xPosition += scrollView.frame.size.width + 2;
xposbut += 500;
UIView *seperatorView = [[UIView alloc] initWithFrame:CGRectMake(xposbut - 50, 4, 2, scrollView.frame.size.height - 8)];
[scrollView addSubview:seperatorView];
xPosition += scrollView.frame.size.width + 4;
[scrollView addSubview: item];
[builder addObject:item];
}
[scrollView setContentSize:CGSizeMake(xposbut, scrollView.frame.size.height)];
[self addSubview:scrollView];
}
을하지만, 나는 다음에 코드의 8 번째 라인을 변경할 때 :
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 400, self.frame.size.width, self.frame.size.height - 69)];
그것은 레이아웃이 잘 보이는 원인이 있지만, 스크롤 뷰는 다음 스크롤되지 않습니다 조금도. 어떤 아이디어?
변경 한 코드 줄은 무엇입니까? –
죄송합니다. 위의 게시물을 편집했습니다. –
적어도 하나의 'contentSize'크기가 'scrollView' 자체 크기보다 커야 어딘가에서 스크롤 할 수 있습니다. –