- (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([[dataArray[indexPath.row] valueForKey:@"type"] isEqual:@"Traffic" ])
        {
            if(!TrafficCell)
            {
                TrafficCell = [tableView dequeueReusableCellWithIdentifier:@"CollectionVIewTableViewCell" forIndexPath:indexPath];
                NSDictionary *dict=dataArray[indexPath.row];
                TrafficCell.Traffic = [dict valueForKey:@"detail"];
                [TrafficCell.collectionView reloadData];
                return TrafficCell;
            }
            return TrafficCell;
        }
    else if([[dataArray[indexPath.row] valueForKey:@"type"] isEqual:@"News"])
    {
        if(!NewsCell)
        {
            NewsTableViewCell *cell = (NewsTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"NewsTableViewCell" forIndexPath:indexPath];
            NSDictionary *dict=dataArray[indexPath.row];
            cell.News = [dict valueForKey:@"detail"];
            [cell.NewsTableView reloadData];
            return cell;
        }
        return NewsCell;
        
    }
    
        else
        {
            if(!CategoryCell)
            {
        CategoryCell= [tableView dequeueReusableCellWithIdentifier:@"CategoryTableViewCell" forIndexPath:indexPath];
                NSDictionary *dict=dataArray[indexPath.row];
                CategoryCell.Category = [dict valueForKey:@"detail"];
                [CategoryCell.CategorycollectionView reloadData];
                return CategoryCell;
            }
            return CategoryCell;
        }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}

解决方案 »

  1.   

    你在创建cell的时候 是根据dataArray和indexPath来创建不同的cell, 那你在点击的时候也可以用dataArray和indexPath来判断点的是哪个cell
      

  2.   

    两种正常的办法:
    1.最正常的办法:适用于页面是静态的不会有改变,直接判断indexpath的row和section来写点击事件
    2.也可以用的办法:适用于每个cell动态创建但保有指针的情况,可以判断一个 cell是否等于被点击的cell(调用cellForRowAtIndexPath这个方法就能得到被点击的cell的指针了),如果是就做处理
      

  3.   

    你可以在didselect方法中通过对dataarray来判断选中的是哪个cell,