码迷,mamicode.com
首页 > 其他好文 > 详细

UITableView的横向使用

时间:2015-03-21 18:31:31      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

  UITableView只支持竖向显示,要实现横向的显示,需要设置tableView 和cell 的transform属性为CGAffineTransformMakeRotate(-M_PI/2)   

// 42.5是TableView的高度,320是UITableView的宽度 _tabTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 66, 42.5, 320)]; _tabTableView.dataSource = self; _tabTableView.delegate = self; _tabTableView.showsVerticalScrollIndicator = NO; _tabTableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设置TableView显示的位置 _tabTableView.center = CGPointMake(320 / 2, 66); _tabTableView.transform = CGAffineTransformMakeRotation(-M_PI_2); [self.view addSubview:_tabTableView];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        TabTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tab"];
        if (cell == nil) {
            cell = [[TabTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"tab"];
        }
        [cell setTitle:_tabArrays[indexPath.row]];
     //这里也要设置一下 cell.transform
= CGAffineTransformMakeRotation(M_PI_2); return cell; }
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
        return 65;//设置横向cell的高度
}

技术分享

UITableView的横向使用

标签:

原文地址:http://www.cnblogs.com/hw140430/p/4355845.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!