SMD01 SMD01 - 4 months ago 16x
iOS Question

Custom Cells Overlapping in UITableView

I have a custom cell class called GameCell, the UI being created in storyboard. When my cells load, they load on top of each other. This problems occurs for cell.clipsToBounds YES and NO, just in different variations:

cell.clipsToBound = YES

cell.clipsToBound = NO

I have also tried [cell setClipsToBounds:(BOOL)] with no success.

Here's my cellForRowAtIndexPath method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @"gameCell";

GameCell *cell = (GameCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell.contentView.superview setClipsToBounds:NO];
NSLog(@"made a cell");
PFObject *myPartners = [ objectAtIndex:indexPath.row];
PFUser *partner = [self.partnerList objectAtIndex:indexPath.row];

// Cell profile image
cell.profileImage.layer.cornerRadius = cell.profileImage.frame.size.width / 2;
cell.profileImage.clipsToBounds = YES;

if([partner objectForKey:@"profilePic"]!=nil){
cell.profileImage.image = [partner objectForKey:@"profilePic"];
else {
cell.profileImage.image = [UIImage imageNamed:@"smile_green.png"];

//Cell indicators
if((int)[myPartners objectForKey:@"sent"]==1){
cell.myIndicator.image = [UIImage imageNamed:@"arrow_icon_dbl.png"];
else if ([myPartners objectForKey:@"sent"]==0){
cell.myIndicator.image = [UIImage imageNamed:@"arrow_icon.png"];

cell.partnerName.text = [myPartners objectForKey:@"receiverName"];
cell.gameId = myPartners.objectId;

// Cell drop shadow
[cell.cellView.layer setShadowColor:[UIColor blackColor].CGColor];
[cell.cellView.layer setShadowOpacity:0.5];
[cell.cellView.layer setShadowRadius:2.0];
[cell.cellView.layer setShadowOffset:CGSizeMake(1.0, 1.0)];

// Cell buttons
if([myPartners objectForKey:@"picture"]!=nil) {
[cell.myPlay setEnabled:NO];
} else {
[cell.myPlay setEnabled:YES];

return cell;

The view is a UITableViewController embedded in a NavigationController


You should make sure that the height of your cell is the RowHeight of your UITableView control.


Cell is designed from XIB, and the height of the view is 30, then make sure:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    return 30.0f;