Так что проблема в моем методе cellForRowAtIndexPath каждый раз, когда indexpath.row только «0». И чтобы подтвердить, что я напечатал счетчик с «count». Но каждый раз он показывает 0, и вся моя таблица распределяется с одинаковыми значениями. Не знаю, что случилось. Пожалуйста, помогите кому-нибудь.indexpath.row показывая индекс 0 каждый раз
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [arr_Max count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 10;
}
-(UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableViewCell";
count=(int)indexPath.row;
NSLog(@"%d",count);
SimpleTableViewCell *cell = (SimpleTableViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.label.text=[NSString stringWithFormat:@"%@",[arr_Max objectAtIndex:count] ];
return cell;
}
Как вы реализованы numberOfRowsInSection? – Woodstock
Пожалуйста, укажите больше кода, чтобы понять вашу проблему. –
Проверить измененную версию – Rahul