1.先在IB上面拉界面,把空間對(duì)應(yīng)ctrl拉到h文件
2.設(shè)置代理和數(shù)據(jù)源
@interface ViewCommitViewController () <UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *commitTableView;
將tableView設(shè)置下
_commitTableView.delegate = self;
_commitTableView.dataSource = self;
進(jìn)行注冊(cè)
- (void)viewDidLoad {
[super viewDidLoad];
_commitTableView.delegate = self;
_commitTableView.dataSource = self;
[self.commitTableView registerNib:[UINib nibWithNibName:@"CommitTableViewCell" bundle:nil] forCellReuseIdentifier:@"cellID"];
在tableView進(jìn)行引用
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CommitTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
設(shè)置行數(shù)
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 4;
}
這樣就自定義xib的cell了