SWRevealTableViewCell
SWRevealTableViewCell copied to clipboard
ios 8: custom subviews of cell get offset twice.
If you try to add a custom element (any view) to your cell's view in IOS8 you'll see that they get away from screen very fast while swiping and they never get back. This is caused by redundant offset modification to the subviews of UITableViewCellContentView after UITableViewCellContentView's offset is modified. In the SWRevealTableViewCell.m : - (void)_setRevealLocation:(CGFloat)xLocation
for ( UIView *view in _revealLayoutView.subviews )
{
// One of the contentView's siblings of is the cell's separatorView.
// We do not want to apply our custom layout to that particular view, so we skip that view based on its class name.
// This is of course hacky and may break in the future. However since we choose to apply our layout directly to the cell, as oposed to
// the cell's contentView we do not have other choice than filtering this here.
// If this code breaks on a future iOS release it will be very easy to fix anyway.
{
if ( [NSStringFromClass([view class]) rangeOfString:@"Separator"].length > 0 )
continue;
}
view.frame = CGRectOffset(view.frame, xLocation, 0 );
}
}
I suppose the only views which frames need to be modified here are SWUtilityContentView and UITableViewCellContentView. However, if you add your subviews to cell.contentView everything works fine.