I added a tableView and dragged a table view cell into it. in the Utilities panel, I changed the style to subtitles. I also tried changing it in code:
- (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;
Center Alignment Doesn't Work!
I tried adding a shortcut object to a cell in order to have a workaround. But I do not know how to access it. although I assigned her a way out, this did not work:
cell.labelForCell....
What should I do? Any suggestions on how I can get it to work in the normal way without adding a shortcut to the cell or something else?
Milad source
share