UIScrollView in UITableViewCell not in scroll mode

advertisements

I am adding a cell to a UITableView which has a scrollview, the code I have in the cell is :

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];

However this does not scroll :(. If I have the same code segment outside the tableview and add this directly to the view, it works as expected. What am I missing?


Try [cell addSubview:scrollView];