我尝试了很多事情,但它显示了单元格

我有添加委托和数据源
tableview.dataSouce = self;
tableview.Delegate =自我;
行高度的func单元
返回44;

我不知道为什么不显示表格视图

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    int count = (int)_dict_contact.count;
    return count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    switch (section) {
        case 0:
        {
            NSArray *arr_email =[_dict_contact objectForKey:@"u_email"];
            int count = (int)arr_email.count;
            return count;
        }
            break;
        case 1:
        {
            NSArray *arr_phone =[_dict_contact objectForKey:@"u_phone"];
            return arr_phone.count;
        }
            break;
     }
    return 0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    MultipleContCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(!cell)
    {
        cell = [[MultipleContCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    switch (indexPath.section) {
        case 0:
        {
             NSArray *arr_email =[_dict_contact objectForKey:@"u_email"];
            cell.detail_lbl.text =[arr_email objectAtIndex:indexPath.row];
              return cell;
        }
            break;
        case 1:
        {
            NSArray *arr_phone =[_dict_contact objectForKey:@"u_phone"];
            cell.detail_lbl.text =[arr_phone objectAtIndex:indexPath.row];
              return cell;
        }
            break;
    }
       return cell;

}

但是尝试了太多之后,我的cellForRowAtIndexPath也没有被调用

最佳答案

您需要在registerNib: forCellReuseIdentifier内为MultipleContCell调用registerClass:forCellReuseIdentifierviewdidload。例如:
[_yourTableView registerNib:[UINib nibWithNibName:@"MultipleContCell" bundle:nil] forCellReuseIdentifier:@"MultipleContCell"];

10-08 07:43