How to make a horizontal UI table view on iPhone?

前端 未结 9 1466
小鲜肉
小鲜肉 2020-12-25 13:59

Normally, the UITableView is something like this:

[   cell    1   ]
[   cell    2   ]
[   cell    3   ]
[   cell    4   ]

But I want to mak

9条回答
  •  星月不相逢
    2020-12-25 14:14

    if you want use textLabel, you can use this:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                          reuseIdentifier:CellIdentifier];
        }
    
    
        cell.textLabel.frame = CGRectMake(0,0, cell.frame.size.width , cell.frame.size.width); // it's very important!!!You must set frame of textLabel, because you can have a problems with displaying you table;
    
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        CGAffineTransform trans = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI_2);
        cell.textLabel.transform = trans;  // rotating you caption;
        cell.textLabel.text = @"tra-tata";
        cell.textLabel.textAlignment = UITextAlignmentCenter;
    
        return cell;
    }
    

提交回复
热议问题