Skip to content

Instantly share code, notes, and snippets.

@lerosua
Created January 6, 2013 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lerosua/4465630 to your computer and use it in GitHub Desktop.
Save lerosua/4465630 to your computer and use it in GitHub Desktop.
创建一个横向的tableview
创建前先设定tableview的rowHeight,然后旋转。
每个row的高度即为旋转后的宽度。然后在cellWillDisplay里旋转一下cell就可以了。
- (UITableView *)payTableView {
if(!_payTableView){
_payTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 320) style:UITableViewStylePlain];
_payTableView.backgroundColor = [UIColor clearColor];
_payTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_payTableView.showsVerticalScrollIndicator = NO;
_payTableView.delegate = self;
_payTableView.dataSource = self;
_payTableView.rowHeight = 320.0;
_payTableView.transform = CGAffineTransformMakeRotation(-1.5707963);
_payTableView.frame = CGRectMake(12, 226, 320, 44);
_payTableView.pagingEnabled = YES;
}
return _payTableView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 160;
}
- (void)tableView:(UITableView *) tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.transform = CGAffineTransformMakeRotation(1.5707963);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment