1. UITableView 设置
CGRect tableViewRect = CGRectMake(0.0, 0.0, 50.0, 320.0);
self.tableView = [[UITableView alloc] initWithFrame:tableViewRect style:UITableViewStylePlain];
tableView.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2);
tableView.delegate = self;
tableView.dataSource = self;
//tableview逆时针旋转90度。
tableView.transform = CGAffineTransformMakeRotation(-M_PI / 2);
// scrollbar 不显示
tableView.showsVerticalScrollIndicator = NO;
2. UITableViewCell 设置
- (UITableViewCell *)tableView :( UITableView *)aTableView cellForRowAtIndexPath :( NSIndexPath*)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier@"identifier"] autorelease];
// cell顺时针旋转90度
cell.contentView.transform = CGAffineTransformMakeRotation(M_PI / 2);
}
return cell;
}
这篇博客介绍了如何设置UITableView以实现横向滚动。首先通过设置frame和transform属性使表格逆时针旋转90度,然后隐藏垂直滚动条。在UITableViewCell中,通过cell.contentView.transform顺时针旋转90度,确保内容正确展示。
1399

被折叠的 条评论
为什么被折叠?



