I am using a custom UITableViewCell
in my app, and I am trying to adjust the frame of the “swipe to delete” button.
This is what I’m doing:
- (void)layoutSubviews {
[super layoutSubviews];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) return;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.0f];
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
CGRect newFrame = subview.frame;
newFrame.origin.x = newFrame.origin.x - 25;
subview.frame = newFrame;
} else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
CGRect newFrame = subview.frame;
newFrame.origin.x = newFrame.origin.x - 25;
subview.frame = newFrame;
}
}
}
It shows up in the new position, which is great. However, when I click away from the button so that it disappears, the button seems to suddenly move about 10 points to the left, and then gets removed.
Why is this happening, and how can I fix it?