Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the best solution is to create subclass UITableViewCell and set the frames of its subiews in <code>layoutSubviews</code> method to suit your spacing requirements. This will be lot cleaner and extendible. <a href="http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW1" rel="nofollow">A closer look at tableview cells</a> is a good read for this.</p> <p>But there are some short-cuts towards this as well, each with its own disadvantages:</p> <ol> <li><p>Set indentation for cells</p> <p><a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40006942-CH3-DontLinkElementID_20" rel="nofollow"><code>-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath</code></a></p> <p>This method will add indentation to your cell contents (left margins). But the cell separator will occupy the actual width of the cell, i.e the table width. So you'll need to set the separator style to none, so that it is won't be shown. But not applicable if you need a cell separator.</p></li> <li><p>Reduce the entire tableViews frame size</p> <p>This is the easiest way and quite obvious, but its lame when you require a margin between cell and the tableView.</p></li> </ol> <p>As you have done it, setting contentInset, you should have noticed the discussion about it in <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/doc/uid/TP40006922-CH3-DontLinkElementID_11" rel="nofollow">Docs</a>.</p> <blockquote> <p>Use this property to add to the scrolling area around the content. The unit of size is points. The default value is UIEdgeInsetsZero. </p> </blockquote> <p>I thought playing with contentOffset and contentSize would help achieve margins, but for me changing the values never had any effect. Probably as Andrey said, they might be managed internally. But I would love to hear more about these properties and their reflected behaviors.</p> <p><strong>EDIT</strong></p> <p>contentOffset and contentSize are inherited from UIScrollView and means same in UITableView as it a subclass of UIScrollView.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload