我加入到具有滾動視圖一個UITableView,我在小區的代碼單元是:的UIScrollView在UITableViewCell中進行滾動
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 30, 320, 44)];
UIView *labelView = [[UIView alloc] initWithFrame:CGRectMake(4, 4, 80 * _labels.count, 44)];
for (NSUInteger i = 0; i < _labels.count; i++) {
NSString *aLabel = [_labels objectAtIndex:i];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i * 70, 3, 60, 30)];
button.tag = i;
[button setTitle:aLabel forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor lightGrayColor]];
[labelView addSubview:button];
}
scrollView.contentSize = CGSizeMake(labelView.frame.size.width, labelView.frame.size.height);
[scrollView addSubview:labelView];
[self addSubview:scrollView];
然而,這並不滾動:(如果我有一樣的。在實現代碼如下外部的代碼段,這直接添加到視圖,它按預期工作我缺少什麼
你試過了嗎[self.contentView addSubview:scrollView]; – Vig 2014-11-14 18:56:36
你是否得到這個工作? – DevC 2015-01-13 15:39:46