【发布时间】:2009-11-10 19:45:40
【问题描述】:
我有一个不能向右滚动的滚动视图,我已经简化了下面的代码。 它绘制视图和一些水平按钮,我在实际代码中添加了更多内容。 如果拖动按钮之间的空白,视图会滚动。如果您碰巧将手指放在按钮上,它将不会滚动。 在提出相关建议后,我尝试添加 delaysContentTouches = YES 行,但似乎没有什么区别。 UIScrollview with UIButtons - how to recreate springboard?
我做错了什么? 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;
}
【问题讨论】:
标签: cocoa-touch uiscrollview uibutton drag