views:

22

answers:

0

Hi all,

i have a uitableview in the uiviewcontroller, i made a scrollview in the viewload event. i am adding it to tableview's first cell. but i scroll the tableview it displays more than one scrollview after 5 cell passed.

here is the code.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"customCell";

    DetailCellViewController *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *nibObjects =[[NSBundle mainBundle] loadNibNamed:@"DetailCellView" owner:nil options:nil];
        for (id currentObject in nibObjects)
        {
            if ([currentObject isKindOfClass:[DetailCellViewController class]])
            {
                cell = (DetailCellViewController *) currentObject;
            }
        }
    }

    if (indexPath.row==0) {
        [cell.contentView addSubview:scrollView];
    }
    else {
        NSMutableDictionary *dictionary=[catData objectAtIndex:indexPath.row-1];
        NSString *title =[dictionary objectForKey:@"title"]];
    [cell.catTitle setText:title];
    }
    return cell;
}

in which event should i add & remove scrollview?