IB创建tableviewcell

IB创建tableviewcell

 

 

 

 

 

 

 

 

 

 

 

 

下面是tablecell的设定 

这是运行的效果,不用代码添加的cell,

附上代码:

#pragma mark -
#pragma mark Table View Data Source Methods
//返回组数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

//返回每组的行数
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    int count;
    if (section == 0) {
        count = 1;
    }
    if (section == 1) {
        count = 4;
    }
    return  count;
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    NSString *title = nil;
    if (section == 0) {
    title = @"登陆";
    }
    if (section == 1) {
        title = @"绑定";
    }
    return title;


}
//设定表行不可选中
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    return nil;

}


- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];
    //设置每行标题
    UITableViewCell *cell = [[UITableViewCell alloc]init];
    if (section == 0) {
        cell = cell0;
 
    }
    if (section == 1 && row == 0) {
        cell = cell1;
    }
    if (section == 1 && row == 1) {
        cell = cell2;
    }
    if (section ==1 && row == 2) {
        cell =  cell3;
    }
    if (section == 1 && row ==3) {
        cell =  cell4;
    }
//      cell.textLabel.text = [nameSection objectAtIndex:row];
     
    
   
  return cell;
   
   
}


IB创建tableviewcell

感觉这样做比较有灵活性减少代码使用量,比较适合像我这样的菜鸟 - -!

第一次写这个 - -多多包涵@。@

你可能感兴趣的:(IB创建tableviewcell)