Reputation: 28905
How can I format a UITableViewCell in my UITableView to have text such as the following:
|Hello======More Text|
where the "|" symbols indicate the beginning and end of the UITableViewCell and the "=" symbold indicate spacing.
So I'm trying to have text A be left justified while at the same time, text B is right justified.
Thanks!
Upvotes: 1
Views: 1147
Reputation: 170859
You can use standard cell with UITableViewCellStyleValue1
style (same cells are used in standard Settings application). Set your "left text" to the cell's textLabel
, and "right text" to the detailTextLabel
, something like:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Left text";
cell.detailTextLabel.text = @"Right text";
return cell;
}
Upvotes: 4