如何值通过xib自定义cell

来源:互联网 发布:朱晓天 人工智能 编辑:程序博客网 时间:2024/05/16 15:28
关键代码如下

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
static NSString *CellIdentifier = @"cell";
     
Cell  *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
if (cell == nil) {
        
//cell=[[Cell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];        //NSArray *cells = [[NSBundle mainBundle] loadNibNamed:@"cell" owner:self options:nil];
        
        
NSArray *nibTableCells = [[NSBundle mainBundleloadNibNamed:@"newcell" owner:self options:nil];
        cell = [nibTableCells 
objectAtIndex:0];
      
        
        
    }
    
NSInteger row=[indexPath row];
    
    cell.
textLabel.text=[datalist objectAtIndex:row];//用数组的数据加载名字!
    
    cell.
accessoryType=UITableViewCellStyleDefault;//后面那个标标的风格;
    
    
    
return cell;

}
我第一次弄的时候一直出错得地方xib连线的问题  
如何值通过xib自定义cell - 吖LAN - 用相机与文字
  


file owner 继承NSobj 而不是定义的cell.h



这里才是继承cell.h


如何值通过xib自定义cell - 吖LAN - 用相机与文字

我不知道对不对,我的理解file owner是对应着viewcontroler这样的控制类,而这次定义view or cell  所以对应要关联的也是cell和 cell.h
0 0
原创粉丝点击