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

UITableView实现横行滑动

时间:2015-06-18 13:10:33      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

- (void)viewDidLoad {

    [super viewDidLoad];

    UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height/2 - 225, CGRectGetWidth(self.view.frame), 25)];

    [headerLabel setBackgroundColor:[UIColor blueColor]];

    [headerLabel setAlpha:0.5];

    [headerLabel setTextColor:[UIColor colorWithRed:172.0/255.0 green:74.0/255.0 blue:93.0/255.0 alpha:1.0]];

    [headerLabel setText:@"庄周梦蝶"];

    [headerLabel setFont:[UIFont systemFontOfSize:18]];

    [self.view addSubview:headerLabel];

    

    UITableView *myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height/2 - 100, 100, self.view.frame.size.height-100)];

    [myTableView.layer setAnchorPoint:CGPointMake(0.0, 0.0)];

    myTableView.transform = CGAffineTransformMakeRotation(-M_PI_2);

    myTableView.dataSource = self;

    myTableView.delegate  = self;

    myTableView.scrollEnabled = YES;

    myTableView.userInteractionEnabled = YES;

    myTableView.showsVerticalScrollIndicator = NO;

    myTableView.frame = CGRectMake(0, self.view.frame.size.height/2 - 100, self.view.frame.size.width, 100);

    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    [myTableView setBackgroundColor:[UIColor whiteColor]];

    [self.view addSubview:myTableView];

    

}

 

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    return 1;

}

 

 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    return 15;

}

 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *identifier = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

    if (cell == nil)

    {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

        cell.selectionStyle = UITableViewCellSelectionStyleBlue;

        self.myLogo = [[LogoView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 100)];

        self.myLogo.tag = 101;

        [cell.contentView addSubview:self.myLogo];

    }

    cell.contentView.transform = CGAffineTransformMakeRotation(M_PI_2);

    

    return cell;

}

 

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return 100;

}

UITableView实现横行滑动

标签:

原文地址:http://www.cnblogs.com/blue-sillyBoy/p/4585273.html

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