#import "ViewController.h"
#import "PlayerCell.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UITableView *_tableview;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self createTableView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)createTableView{
_tableview = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_tableview.backgroundColor = [UIColor groupTableViewBackgroundColor];
_tableview.dataSource = self;
_tableview.delegate = self;
[self.view addSubview:_tableview];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellID = @"cell";
PlayerCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil){
//#ifdef _1
// [tableView registerNib:[UINib nibWithNibName:@"PlayerCell" bundle:nil] forCellReuseIdentifier:@"cell"];
// cell = [tableView dequeueReusableCellWithIdentifier:cellID];
//#elif _0
cell = [[[NSBundle mainBundle] loadNibNamed:@"PlayerCell" owner:self options:nil]lastObject];
//#endif
}
cell.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:1];
return cell;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{\
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 6;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100;
}
@end
#import "PlayerCell.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UITableView *_tableview;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self createTableView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)createTableView{
_tableview = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_tableview.backgroundColor = [UIColor groupTableViewBackgroundColor];
_tableview.dataSource = self;
_tableview.delegate = self;
[self.view addSubview:_tableview];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellID = @"cell";
PlayerCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil){
//#ifdef _1
// [tableView registerNib:[UINib nibWithNibName:@"PlayerCell" bundle:nil] forCellReuseIdentifier:@"cell"];
// cell = [tableView dequeueReusableCellWithIdentifier:cellID];
//#elif _0
cell = [[[NSBundle mainBundle] loadNibNamed:@"PlayerCell" owner:self options:nil]lastObject];
//#endif
}
cell.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:1];
return cell;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{\
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 6;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100;
}
@end