search

Home  >  Q&A  >  body text

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


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

高洛峰高洛峰2889 days ago336

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:25:36

    Idea 1: As on the first floor, using UICollectionView, you can place 2 Cells in one row
    Idea 2: Continue to use UITableView and put two Views in one cell

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:25:36

    Use UICollectionView

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 09:25:36

    Collection view is better, more direct, but two views are not.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:25:36

    - (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;
             }

    reply
    0
  • Cancelreply