Ios 应用程序在-[UITableView\u configureCellForDisplay:forIndexPath:]中退出***断言失败
这是我的Ios 应用程序在-[UITableView\u configureCellForDisplay:forIndexPath:]中退出***断言失败,ios,objective-c,uitableview,Ios,Objective C,Uitableview,这是我的UITableView代码。每当加载视图时,我都会收到以下错误: ***在-[UITableView\u configureCellForDisplay:forIndexPath:]、/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit\u Sim/UIKit-3512.30.14/UITableView.m:7962中断言失败 UITableView(;layer=;contentOffset:{0,0};contentSize:{
UITableView
代码。每当加载视图时,我都会收到以下错误:
***在-[UITableView\u configureCellForDisplay:forIndexPath:]、/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit\u Sim/UIKit-3512.30.14/UITableView.m:7962中断言失败
UITableView(;layer=;contentOffset:{0,0};contentSize:{343,190}>)未能从其数据源()获取单元格
创建表的方法是相同的。我使用TableView已经有很长时间了。然而,我没能找出这是错的
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
case 0:
return 70;
break;
case 1:
return 50;
break;
case 3:
return 50;
break;
default:
return 70;
break;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *Id = @"CellID2";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:Id forIndexPath:indexPath];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Id];
}
UILabel *object = (UILabel *)[cell.contentView viewWithTag:1];
UILabel *discription = (UILabel *)[cell.contentView viewWithTag:2];
object.text = [array objectAtIndex:indexPath.row];
switch (indexPath.row) {
case 0:
discription.text = self.Location;
break;
case 1:
discription.text = self.LocationType;
break;
case 3:
discription.text = self.rating;
break;
default:
break;
}
return nil;
}
信息:
无法从其数据源获取单元格
表示您正在为cellforrowatinexpath
方法返回nil
更改返回nil
到返回单元格
在您的cellforrowatinexpath
方法的末尾。消息:
无法从其数据源获取单元格
表示您正在为cellforrowatinexpath
方法返回nil
更改返回nil
到返回单元格
在cellforrowatinexpath
方法的末尾