我尝试了很多东西,但它显示单元格
我已经添加委托(delegate)和数据源 tableview.dataSouce =self; tableview.Delegate = self; 行高的函数单元格 返回 44;
我不知道为什么表格 View 不显示
-(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 也没有被调用
最佳答案
您需要为 viewdidload
中的 MultipleContCell 调用 registerNib:forCellReuseIdentifier
或 registerClass:forCellReuseIdentifier
。例如:
[_yourTableView registerNib:[UINib nibWithNibName:@"MultipleContCell"bundle:nil] forCellReuseIdentifier:@"MultipleContCell"];
关于ios - 未调用 cellForRowAtIndexPath,行数、节数和单元格高度返回正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43495627/