UITableView create 4 square

后端 未结 2 1819
陌清茗
陌清茗 2020-12-22 07:20

I want to create calendar view with UITableView

I want to have 4 square in each rows like the below picture:

would you please help me, how can I have 4 squ

相关标签:
2条回答
  • 2020-12-22 07:50

    Try out this code:-

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
       static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease]; 
        }
       cell.selectionStyle = UITableViewCellSelectionStyleNone;
    int column = 4;
    
       for (int i=0; i<column; i++) {
    
            UIImageView *aBackgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(32+184*i,10, 167,215)];
            aBackgroundImageView.tag = (column*indexPath.row)+i;
            [cell.contentView addSubview:aBackgroundImageView];
            [aBackgroundImageView release];
        }
      return cell;
    }
    

    Column will number of items you want in one cell.

    0 讨论(0)
  • 2020-12-22 08:11

    If you want to create a calendar view, check out this code for some ideas (depending on what you want to achieve).

    To create a UITableView row with four equally sized cells, just implement the tableView:cellForRowAtIndexPath: datasource method to create a view with e.g. four equally sized UILabels.

    0 讨论(0)
提交回复
热议问题