Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UItableviewcontroller doesnt display data in rows and creates extra row

enter image description hereenter image description here

I have created UITableViewController. I have a NSMutableArray with three records. I have created a custom UITableViewCell class and linked it with TableViewCell. But when running the program my tableview displays below output. There are only three records but table view shows 5 rows and all my data are showed in first row itself.

-(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

-(NSUInteger)callRecordsCount{
    return [self.callRecordsList count];
}

- (callRecords *)callRecordAtIndex:(NSUInteger)index{
   return [self.callRecordsList objectAtIndex:index];
}
like image 463
Jeeva Avatar asked Jul 15 '26 09:07

Jeeva


1 Answers

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 simulator iphone7 simulator

like image 112
Jeeva Avatar answered Jul 17 '26 22:07

Jeeva