Im having an interesting issue in viewing cells in tableview:
At first when the tableview is loaded the cells look a bit blurry, the weird thing is that when showing and then hiding the keyboard they’ll be fixed till sliding the table again (dequeuing new cells).


In general there are 3 types of cells in that tableview (CustomCellWithButton, AddSlidesCells and CustomCell). the blurry can be found in all of them but it is clearly seen in CustomCell. It is making me crazzzzy :S Please Help
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier;
if((indexPath.section == 4 && (indexPath.row == 1)))
{
CellIdentifier = @"CustomCellWithButton";
CustomCellWithButton *cell = (CustomCellWithButton*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellWithButton" owner:nil options:nil];
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCellWithButton *)currentObject;
break;
}
}
}
[cell.button addTarget:self action:@selector(nextButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell setBackgroundColor:[UIColor darkGrayColor]];
return cell;
}
else
{
if((indexPath.section == 3 && (indexPath.row == 0))){
CellIdentifier = @"AddSlidesCells";
AddSlidesCells *cell = (AddSlidesCells*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"AddSlidesCells" owner:nil options:nil];
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (AddSlidesCells *)currentObject;
break;
}
}
}
[cell.switchButton setOn:[self getswitchButtonsStatesByIndexPath:indexPath] withIndexpath:indexPath];
[cell.switchButton addTarget:self action:@selector(switchChanged:forEvent:)
forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)];
[cell.button addTarget:self action:@selector(addSlicePressed:) forControlEvents:UIControlEventTouchDown];
NSLog(@" ---- here add to dismiss keyboared");
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell setBackgroundColor:[UIColor darkGrayColor]];
if (alignedLeft) {
[cell hardAllignToLeft];
}else
[cell hardAllignToRight];
return cell;
}
else
{
CellIdentifier = @"CustomCell";
BOOL dequed;
CustomCell *cell = (CustomCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString* placeHolder = [self getplaceHoldersByIndexPath:indexPath];
if (cell == nil) {
dequed = NO;
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil options:nil];
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *)currentObject;
[cell setFrame:CGRectMake(0, 0, 320, 50)];
break;
}
}
}else
dequed = YES;
cell.alignedLeft = alignedLeft;
[cell.textField setPlaceholder:placeHolder];
[cell.textField setText:[self getTextfieldByIndexPath:indexPath] andIndexPath:indexPath];
[cell.switchButton setOn:[self getswitchButtonsStatesByIndexPath:indexPath] withIndexpath:indexPath];
[cell.switchButton addTarget:self action:@selector(switchChanged:forEvent:)
forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)];
[cell.textField addTarget:self action:@selector(UIControlEventEditingChanged:)
forControlEvents:UIControlEventEditingChanged];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.textField.delegate = self;
if( [placeHolder isEqualToString:[OperationsOnCoreData PlistCommonStrings:@"Telephone"]] ||
[placeHolder isEqualToString:[OperationsOnCoreData PlistCommonStrings:@"Email"]]){
cell.plusSignButton.hidden = NO;
cell.minusSignButton.hidden = YES;
[cell.plusSignButton addTarget:self action:@selector(plusSignButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
}
else
if(( !([placeHolder rangeOfString:[NSString stringWithFormat:@"%@ ",[OperationsOnCoreData PlistCommonStrings:@"Telephone"]]].location == NSNotFound)||
!([placeHolder rangeOfString:[NSString stringWithFormat:@"%@ ",[OperationsOnCoreData PlistCommonStrings:@"Email"]]].location == NSNotFound))){
cell.minusSignButton.hidden = NO;
cell.plusSignButton.hidden = YES;
[cell.minusSignButton addTarget:self action:@selector(minusSignButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
}
else{
cell.minusSignButton.hidden = YES;
cell.plusSignButton.hidden = YES;
}
if(cell.switchButton.on){
[cell.textField setEnabled:YES];
cell.textField.alpha = 1;
}else{
[cell.textField setEnabled:NO];
cell.textField.alpha = 0.5;
cell.plusSignButton.enabled = NO;
cell.minusSignButton.enabled = NO;
}
[cell setBackgroundColor:[UIColor darkGrayColor]];
if (alignedLeft) {
[cell hardAllignToLeft];
}else
[cell hardAllignToRight];
return cell;
}
}
}
The blurry cells look blurry because the elements are one pixel less high than the non-blurry ones. So the blurry look is caused by the resizing of the switch button and the plus icon.
To fix it, you’ll need to investigate the layout of your cell, in particular how these elements sized. They probably should always take their natural size. The pasted code doesn’t contain the relevant parts.