I have an issue in one of my projects. I have one tableview like in the picture. My issue is my custom cell background is overlapping the UITableView delete button. Could any one please help me to bring it to front.
I have used below code but some of the developers are saying that If we use that code Apple may be reject your app
- (void)layoutSubviews
{
[super layoutSubviews];
for (UIView *subview in self.subviews) {
for (UIView *subview2 in subview.subviews) {
//NSLog(@"confirm is %@",[subview2 class]);
if ([NSStringFromClass([subview2 class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"])
{
// move delete confirmation view
[subview bringSubviewToFront:subview2];
} else if ([NSStringFromClass([subview2 class]) isEqualToString:@"_UITableViewCellActionButton"])
{
[subview bringSubviewToFront:subview2];
}
}
}
}
another issue is the below code is only working upto iOS 7 but not working in iOS 8.
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath;
method to YES I don't have issues but we don't want indent.Any ideas could be very helpful.
You need to add a button into contentView, not to cell view directly
Hierarchy of UITableViewCell
subviews is different in iOS 7 and iOS 8, try my solution.
- (void)layoutSubviews {
[super layoutSubviews];
for (UIView *subview in self.subviews) {
// for iOS 8
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) {
[self bringSubviewToFront:subview];
return;
}
// for iOS 7
for (UIView *subview2 in subview.subviews) {
if ([NSStringFromClass([subview2 class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) {
[subview bringSubviewToFront:subview2];
return;
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With