I am using a custom UITableViewCell in my app and everything was working fine until I started using iOS 8. All my custom class does is reduce the width of the table rows so I get some margin on the left and right of my iPhone screen.
Here is the interface for my class:
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell
@end
In the implementation, I have a setFrame method that adds margins on the left and right of the cell, like so:
@implementation CustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
// reduce cell width to add margins
- (void)setFrame:(CGRect)frame {
frame.origin.x += 10;
frame.size.width -= 2*10;
[super setFrame:frame];
}
@end
The above approach works fine on iOS 7.1. I can swipe one of the rows in my UITableView to the left to reveal the Delete button. The remaining rows are not affected by this swipe gesture. When I tap on the swiped row, the delete button goes away and the row is returned to its normal position.
In iOS 8, when I swipe one row to left to reveal the Delete button, the views for all rows seem to get affected. Plus, it appears that the block inside the setFrame method is executed again and again while we are swiping the row to the left - and not just for the current row. This makes a complete mess of the views for all the visible rows in the table.
If I do not mess with the frame origin and the width in my custom class, everything works fine, but then I have no margins.
Has anyone experienced this behavior in iOS 8? Is there a better way to add margins?