首页 > uitableview如何将每行添加两个cell,数据是后台传输的

uitableview如何将每行添加两个cell,数据是后台传输的


这个uitableview如何在每行添加两列数据,在线等


思路一:如一楼,使用UICollectionView,可以一行放置2个单元Cell
思路二:继续使用UITableView,在一个单元格中放入两个View


用UICollectionView


还是collection view好啊,直接,两个view不行。


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return (List.count)/2+1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    NSUInteger row=[indexPath row];
    
    UIView *v1 = cell.leftView;
    UIView *v2 = cell.rightView;
    GoodsList *subInfo=nil;
    
    for (NSInteger i = 0; i < 2; i++)
    {
        //奇数
        if (row*2+i >List.count - 1)
        {
            v2.hidden = YES;
            break;
        }
        subInfo = [List objectAtIndex:row*2 + i];
        if (i==0)
        {
            v1.hidden = NO;
         }else{
             v2.hidden = NO;
         }
【热门文章】
【热门文章】