IOS 读取xib到tabelView

 

 

/**每一行显示怎样的ceLl*/
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //1.创建cell
    MJtgCell *cell=[MJtgCell cellWithTableView:tableView];
    //2.给cell传递模型数据
    cell.tg=self.tgs[indexPath.row];
    
    return cell;
}

 

 

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"tg";
    MJTgCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        //MJTgCellxib中加载cell 
cell = [[[NSBundle mainBundle] loadNibNamed:@"MJTgCell" owner:nil options:nil] lastObject];
}
return cell;
}

 

posted on 2017-02-24 10:23  守望星空  阅读(154)  评论(0编辑  收藏  举报

导航