Reputation: 14622
I want to take a table the following cells:
The_main_cell_text_1
Detail_1 Detail_2
The_main_cell_text_2
Detail_3 Another_Detail_4
How to add cell's detailText with left and right alignment (both)?
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@...<dynamic_space>...%@", detail_1, detail_2];
Upvotes: 0
Views: 243
Reputation: 9977
Actually you should subclass uitableviewcell and add three custom labels to the contentview.
But to stay in your string based approach you could calculate the size of your two strings [string sizeWithFont: ...] and then calculate the appropriate count of spaces needed to have the look of a left aligned and a right aligned text.
approach 3 could be to just add one additional label onto cell.contentView, ehich is right aligned.
Upvotes: 3