0

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 = [self.games 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

SMD01
  • 101
  • 1
  • 13
  • It looks like you need to return a taller height for the rows of your table view (with rowHeight property or the delegate method, tableView:heightForRowAtIndexPath:) – rdelmar Aug 26 '14 at 03:47
  • Check this may help you : http://stackoverflow.com/questions/22358831/ios-7-1-uitableviewcell-content-overlaps-with-ones-below – Dhaval Bhadania Aug 26 '14 at 04:52

3 Answers3

3

You have used dequeueReusableCellWithIdentifier:

use like this

NSString *CellIdentifier = [NSString stringWithFormat:@"Cell %d",indexPath.row];

UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];

if (cell == nil)
{
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

and also check this link.

UITableView cell Contents are disappearing and overlapping when scrolled in UITableViewcell?

Community
  • 1
  • 1
Ganesh Kumar
  • 708
  • 6
  • 25
2

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

e.g.,

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;
}
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
-1

In attributes inspector cancel Adjust Scroll view insets option.

you need clicked view controller .

Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194
Neal
  • 45
  • 1
  • 5