Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView Overlaying cells on top of each other
    primarykey
    data
    text
    <p>I thought my table was fine until I changed the backgrounds to be a little transparent, which showed previous cells underneath new dequeued cells. This is the code in my <code>tableView:cellForRowAtIndexPath:</code> method. I took out redundant label set up, which are all the same as <code>timeLabel</code>. </p> <pre><code>static NSString* cellIdentifer = @"Cell"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: cellIdentifer]; if (!cell) { cell= [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: cellIdentifer]; } int offset = 5; int rowHeight = 120; UIView* cellView = [[UIView alloc] initWithFrame: CGRectMake(offset, offset, 320 - offset * 2, rowHeight - offset * 2)]; cellView.backgroundColor = indexPath.row % 2 == 0 ? [UIColor colorWithWhite: 1.0 alpha: .8 ] : [UIColor colorWithWhite: .3 alpha: .8]; int padding = 5; int x1 = 5; int x2 = CGRectGetWidth(cellView.frame) / 3; int x3 = x2 * 2; int y1 = 5; int y2 = CGRectGetHeight(cellView.frame) / 2 + padding; int width = CGRectGetWidth(cellView.frame) / 3 - padding; int sHeight = CGRectGetHeight(cellView.frame) / 2 - padding; int bHeight = CGRectGetHeight(cellView.frame) - padding; CGRect cell1 = CGRectMake(x1, y1, width, sHeight); int row = indexPath.row;// - 1; UILabel* timeLabel = [[UILabel alloc] initWithFrame: cell1]; timeLabel.backgroundColor = [UIColor clearColor]; timeLabel.text = [[self.tableData objectAtIndex: row] objectForKey: @"time"]; [cellView addSubview: timeLabel]; [cell.contentView addSubview: cellView]; </code></pre> <p><img src="https://i.stack.imgur.com/kbfrd.png" alt="Here&#39;s a screenshot of what&#39;s happening"></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.
 

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