오른쪽으로 스크롤되지 않는 스크롤 뷰가 있는데 아래 코드를 단순화했습니다. 실제 코드에서 더 많은 내용을 추가하는보기 및 일부 가로 단추를 그립니다. 버튼 사이에 공백을 드래그하면보기가 스크롤됩니다. 버튼에 손가락을 대면 스크롤되지 않습니다. 관련 제안을 한 후에 delaysContentTouches = YES 줄을 추가하려고 시도했지만 차이가 나는 것 같지 않습니다. UIScrollview with UIButtons - how to recreate springboard?UIScrollView는 자식 뷰가 히트되지 않은 경우에만 작동합니다.
내가 뭘 잘못하고 있니? TIA, 롭
코드
- (void)viewDidLoad {
l = [self landscapeView];
[self.view addSubview:l];
[l release];
}
- (UIScrollView *) landscapeView {
// LANDSCAPE VIEW
UIScrollView *landscapeView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 325)];
landscapeView.backgroundColor = [UIColor whiteColor];
landscapeView.delaysContentTouches = YES;
NSInteger iMargin, runningY, n;
iMargin = 3;
runningY = iMargin;
for (n = 1; n <= 38; n++) {
//add day labels
UIButton *templabel = [[UIButton alloc] initWithFrame:CGRectMake(iMargin,runningY,320 - (2 * iMargin),20)];
templabel.backgroundColor = [UIColor grayColor];
[landscapeView addSubview:templabel];
[templabel release];
runningY = runningY + 30;
}
landscapeView.contentSize = CGSizeMake(320, runningY);
return landscapeView;
}
에게 업데이트
생각하지 마십시오 그래서 코드를 업데이트했습니다. – dny238