У меня есть приложение для хранения, в котором вы вводите имя и фамилию отдельно, и мне было интересно, можно ли поместить имена в один и тот же элемент tableView.Несколько имен массивов в одном месте
Вот мой Tableview код:
#pragma mark UITableViewDataSource Methods
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"cell"];
if (nil == cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
NSLog(@"indexPath.row = %d, patients.count = %d", indexPath.row, patients.count);
Patient *thisPatient = [patients objectAtIndex:indexPath.row];
cell.textLabel.text = thisPatient.patientName;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.textColor = [UIColor blackColor];
if (self.editing) {
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [patients count];
}
#pragma mark UITableViewDelegate Methods
- (void) tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[patients removeObjectAtIndex:indexPath.row];
[tv deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
}
- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
LSAppDelegate *delegate = (LSAppDelegate *)[[UIApplication sharedApplication] delegate];
PatientController *patient = [[PatientController alloc] initWithIndexPath:indexPath];
[delegate.navController pushViewController:patient animated:YES];
[tv deselectRowAtIndexPath:indexPath animated:YES];
}
Я попытался cell.textLabel.text = thisPatient.patientName, thisPatient.patientSurname;
Хотя это показывает только первое имя, в то время как оно должно отображаться имя и фамилия Заранее спасибо
Где вы владеете этой информацией? если у вас есть пул, к которому можно получить доступ в методе cellForRowAtIndexPath, вам просто нужно это сделать – geo
Я храню информацию в базе данных, которая читается при загрузке файла –
, у вас есть несколько вариантов размещения информации в вашей ячейке. В зависимости от ваших требований вы можете изменить ** стиль ** ячейки и установить «detailTextLabel» или объединить обе в простой строке с «stringWithFormat» или «stringByAppandingFormat» – geo