How can I increase the space between the title and subtitle in UITableViewCell?
-
you can use custom tableview cell see this link http://stackoverflow.com/questions/16634738/how-to-create-a-uitablecell-that-has-multiple-subtitles/16635190#16635190 – Ayush Aug 10 '13 at 05:14
-
removed salutation: "Thanks in advance..", don't do it next time :) – hello_there_andy May 18 '15 at 19:01
5 Answers
subclass UITableViewCell to create a custom cell. Here is a great way to do this. It's simple and will also allow you future potential in making your cells look the way you want them to. The other nice thing about it is that each cell is generic, so you only have to create one customized class.
You can add two labels in your cell content view instead of setting cell label. Adjust the y origin as per need. Adding heightForRowAtIndexPath will increase your cell height.

- 939
- 10
- 23
The best way would be to just subclass UITableViewCell. That way, you can have total and complete control over the position of the labels. If this is not an option, you could modify each label's frame manually.

- 129,200
- 40
- 280
- 281
If your row height is greater then the title and subtitle will be vertically middle align.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}

- 1,220
- 11
- 16
- create a custom cell.
- new file->user interface-> empty
- name for your custom cell-> drag and drop a table view cell.
- now you have complete control. you can place your label anywhere.
- give a identifier name for your custom cell.
- create a class (subclass of
UITableViewCell
) for your custom cell.- set property for your labels.
- synthesize property in .m
- make connection for your labels from IB.
update your table view class.
- import custom cell's class.
use your custom cell's identifier in
cellForRowAtIndexPath
.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = YOUR CUSTOM CELL's IDENTIFIER; SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } //configure your cell. cell.YOURLABEL1.text=@"YOUR TEXT FOR LABEL 1"; cell.YOURLABEL2.text=@"YOUR TEXT FOR LABEL 2" return cell; }
thats It.

- 6,405
- 16
- 66
- 120

- 5,663
- 7
- 32
- 65