[英]UItableviewcontroller doesnt display data in rows and creates extra row
I have created UITableViewController
. 我创建了
UITableViewController
。 I have a NSMutableArray
with three records. 我有一个
NSMutableArray
有三个记录。 I have created a custom UITableViewCell
class and linked it with TableViewCell
. 我创建了一个自定义的
UITableViewCell
类并将其与TableViewCell
链接。 But when running the program my tableview displays below output. 但是在运行程序时,我的tableview显示在输出下方。 There are only three records but table view shows 5 rows and all my data are showed in first row itself.
只有三个记录,但表视图显示5行,我的所有数据都显示在第一行本身。
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
callRecordsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CallRecordsCell" forIndexPath:indexPath];
callRecords *record = [self.callRecordsDataController callRecordAtIndex:indexPath.row];
NSLog(@"Indexpath row now is %d",indexPath.row);
cell.callRecordOriginalDestinationLabel.text = record.originalDestination_Alias;
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"dd-MMM"];
cell.callRecordStartTime.text = [[NSString alloc]initWithString:[df stringFromDate:record.start_Time]];
cell.callRecordCallDuration.text = record.call_Duration;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSLog(@"count is %d",[self.callRecordsDataController callRecordsCount]);
return [self.callRecordsDataController callRecordsCount];
}
DataController code DataController代码
-(NSUInteger)callRecordsCount{
return [self.callRecordsList count];
}
- (callRecords *)callRecordAtIndex:(NSUInteger)index{
return [self.callRecordsList objectAtIndex:index];
}
I found the problem.it was because of rendering issues in iphone7plus simulator.i ran the same project in other simulators it was displaying it correctly. 我找到了问题。因为iphone7plus模拟器中的渲染问题。我在其他模拟器中运行了相同的项目,它正确显示它。
There are only three records but table view shows 5 rows and all my data are showed in first row itself.can somebody help??
只有三个记录,但表视图显示5行,我的所有数据都显示在第一行本身。有人帮忙??
My guess, 我猜,
Please screecap the storyboard and post your cell design. 请筛选故事板并发布您的单元格设计。
Also read this tutorial about creating custom cell with storyboard: https://www.appcoda.com/ios-programming-customize-uitableview-storyboard/ 另请阅读本教程,了解如何使用故事板创建自定义单元格: https : //www.appcoda.com/ios-programming-customize-uitableview-storyboard/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.