How to make a horizontal UI table view on iPhone?

前端 未结 9 1443
小鲜肉
小鲜肉 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条回答
  •  -上瘾入骨i
    2020-12-25 14:29

    Use a UIViewController with a UIView, add the UITableView of your table to the controller view, then in terms of code is just one line:

    - (void)viewDidLoad
    {
    
        [super viewDidLoad];
    
        // horizontal table
        // -90 degrees rotation will move top of your tableview to the left
        myTableView.transform = CGAffineTransformMakeRotation(-M_PI_2);
        //Just so your table is not at a random place in your view
        myTableView.frame = CGRectMake(0,0, myTableView.frame.size.width, myTableView.frame.size.height);
    ...
    

提交回复
热议问题