UITableViewCell not clipping to borders during extension animation
I am trying to implement a fairly simple tabular view with an expanding cell containing a UIDatePicker, with autoplay / freemasonry cells and auto-sized.
I have a problem with the expanding date picker cell. When the cell containing the date picker starts to expand, its content appears outside the cell, although I have clipsToBounds = YES
both for the cell itself and for the cell.contentView. I also tried reinstalling clipsToBounds = YES
after layoutSubviews
.
Sorry for the quality, but here is a gif showing the problem of animation in slow motion.
Any ideas on how I can store the date picker in my cell? Any help would be greatly appreciated!
Perhaps the relevant code snippets:
Insert / Delete
[self.tableView beginUpdates];
if (showingStartTimePicker) {
[sections[TableSectionTimes] insertObject:@(TableRowStartTimePicker) atIndex:index];
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:TableSectionTimes]] withRowAnimation:UITableViewRowAnimationTop];
} else {
[sections[TableSectionTimes] removeObject:@(TableRowStartTimePicker)];
[self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:TableSectionTimes]] withRowAnimation:UITableViewRowAnimationTop];
}
[self.tableView endUpdates];
DatePickerCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setClipsToBounds:YES];
[self.contentView setClipsToBounds:YES];
_picker = [UIDatePicker new];
[self.contentView addSubview:_picker];
[_picker makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.contentView);
}];
}
return self;
}
source to share