- @interface FirstViewController ()
- @end
- static NSString *MyCellID = @"thisIsMyCellId";
- @implementation FirstViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.view.backgroundColor = [UIColor whiteColor];
- self.tableDataArray = @[[UIColor redColor], [UIColor yellowColor], [UIColor blueColor]];
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.scrollsToTop = NO;
- self.tableView.transform = CGAffineTransformMakeRotation(-M_PI_2);
- self.tableView.showsVerticalScrollIndicator = NO;
- self.tableView.pagingEnabled = YES;
- self.tableView.bounces = NO;
- [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:MyCellID];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.tableDataArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return tableView.frame.size.width;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:MyCellID forIndexPath:indexPath];
- cell.contentView.transform = CGAffineTransformMakeRotation(M_PI_2);
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- UIColor *color = [self.tableDataArray objectAtIndex: indexPath.row];
- [cell.contentView setBackgroundColor: color];
- return cell;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
#define COLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#import "TableViewController.h"
@interface TableViewController ()
@property NSMutableArray *tableDataArray;
@end
static NSString *MyCellID =@"thisIsMyCellId";
@implementation TableViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColorwhiteColor];
self.tableDataArray = [NSMutableArrayarray];
for (int i =0; i< 20; i++) {
int r = arc4random()%255 ;
int g = arc4random()%255 ;
int b = arc4random()%255 ;
[self.tableDataArray addObject: COLOR(r, g, b)];
}
//tableview逆时针旋转90度。
self.tableView.transform = CGAffineTransformMakeRotation(-M_PI /2);
// scrollbar 不显示
self.tableView.showsVerticalScrollIndicator =NO;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
returnself.tableDataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"identifier"];
if (cell == nil) {
cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:@"identifier"];
// cell顺时针旋转90度
cell.contentView.transform =CGAffineTransformMakeRotation(M_PI /2);
}
UIColor *color = [self.tableDataArrayobjectAtIndex: indexPath.row];
[cell.contentView setBackgroundColor: color];
return cell;
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end