He añadido un tableView y arrastrado una celda de vista de tabla en él. en el panel de utilidades, cambié el estilo a subtítulo. También he intentado cambiar en el código: alineacióniOS - Alineación de texto UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.textAlignment = UITextAlignmentCenter;
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
cell.textLabel.text = [myArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [myArray2 objectAtIndex:indexPath.row];
return cell;
El centro no funciona!
He intentado agregar un objeto de etiqueta a la celda para tener una solución. Pero no sé cómo acceder a él. aunque le asigné una toma de corriente, esto no funcionaría:
cell.labelForCell....
¿Qué debo hacer? alguna sugerencia sobre cómo hacer que funcione de la manera habitual, sin agregar una etiqueta a la celda o algo así?
Solo un fyi, use NSTextAlignmentCenter. UITextAlignmentCenter está en desuso. – Viper