之前寫的有不少人反應(yīng)不好用涨冀,現(xiàn)在更新一個我常用的方法,有興趣的可以試試。采用的是注冊的方式荠割。
//viewDidLoad中
-(void)createTableView
{
UITableView*tableView = [[UITableViewalloc]initWithFrame:CGRectMake(0,0,kMainScreenWidth,kMainScreenHeight)style:UITableViewStyleGrouped];
tableView.delegate=self;
tableView.dataSource=self;
tableView.showsVerticalScrollIndicator=NO;
tableView.showsHorizontalScrollIndicator=NO;
tableView.backgroundColor= [UIColorcolorWithHexString:@"#F2F2F2"];
tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
tableView.mj_header= [MJRefreshNormalHeaderheaderWithRefreshingTarget:selfrefreshingAction:@selector(_loadNewData)];
[self.viewaddSubview:tableView];
[tableViewregisterNib:[UINibnibWithNibName:@"ZKMessageTableViewCell"bundle:nil]forCellReuseIdentifier:@"ZKMessageTableViewCell"];
}
//只寫一個關(guān)鍵的cellForRow方法棵帽,其他的方法都一樣寫法熄求。
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
ZKMessageTableViewCell*cell = [tableViewdequeueReusableCellWithIdentifier:@"ZKMessageTableViewCell"];
return cell;
}