Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableViewCell background size
    text
    copied!<p>I'm trying to set the size of my background to be a little shorter than the default, creating some space between the cells. This has proven to be difficult. Setting the frame of the background view seems to do nothing:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *reuseIdentifier = @"cell"; UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if (!cell) cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:reuseIdentifier] autorelease]; // Set up the cell... cell.contentView.backgroundColor = [UIColor clearColor]; cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectMake(0, 4, 320, 42)] autorelease]; cell.backgroundView.backgroundColor = [UIColor blackColor]; cell.backgroundView.alpha = .2; cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:CGRectMake(0, 4, 320, 42)] autorelease]; cell.selectedBackgroundView.backgroundColor = [UIColor whiteColor]; cell.selectedBackgroundView.alpha = .2; cell.font = [UIFont fontWithName:@"MarkerFelt-Thin" size:22.0f]; cell.selectedTextColor = [UIColor blackColor]; cell.textColor = [UIColor whiteColor]; NSDictionary *dict = [files objectAtIndex:indexPath.row]; cell.text = [dict objectForKey:@"name"]; return cell; } </code></pre> <p>Any help?</p> <p>Also, setting the selected background view doesn't do anything. When a cell is selected, the background is completely blank. Why is this?</p> <p>I'm using iPhone OS 2.2.1.</p> <p>I also do this:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.rowHeight = 50.0f; } </code></pre> <p>You can download the code here (made a small project for this issue only):</p> <p><a href="http://dl.dropbox.com/u/608462/tabletest2.zip" rel="nofollow noreferrer">http://dl.dropbox.com/u/608462/tabletest2.zip</a></p>
 

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