Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using background view for UITableViewCell in iOS 7 covers default delete button

I am using background view for UITableviewCell which is an imageview, I am using the image view to achieve two side corners for first and last cell. It is working fine But the problem is when I use this background view, the default cell delete button which comes when we press the tableviewcell default edit button is being covered by the background view.If I give clear color for the background view it is working fine but I want background view to be set.

Is there any idea why the delete button is being covered or hidden by cell background view? It happens in iOS 7 Please help! thanks in advance.

like image 758
Techie Avatar asked Oct 01 '13 04:10

Techie


3 Answers

how about instead of using the background view. just use your image as the background patternn color try using this

cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:YOUR_IMAGE]];
like image 174
ReyJenald Avatar answered Sep 28 '22 07:09

ReyJenald



Had the exact same issue. Solved it by sending the backgroundView to back when transition starts & also again on the next runloop cycle (using dispatch_async).

Here's the code you should add to your cell class .m file (i.e. MyCustomTableCellView.m)

// Fix for iOS7, when backgroundView comes above "delete" button
- (void)willTransitionToState:(UITableViewCellStateMask)state {
    [super willTransitionToState:state];
    [self sendSubviewToBack:self.backgroundView];
    dispatch_async(dispatch_get_main_queue(), ^{
        [self sendSubviewToBack:self.backgroundView];
    });
}

- (void)didTransitionToState:(UITableViewCellStateMask)state {
    [super didTransitionToState:state];
    [self sendSubviewToBack:self.backgroundView];
}
like image 31
Avishay Cohen Avatar answered Sep 28 '22 09:09

Avishay Cohen


I spoke with an Apple UIKit engineer today at the iOS 7 Tech Talks event in SF, and confirmed that this is an open bug that will be fixed "soon" by Apple.

UPDATE 10/22/13: iOS 7.0.3 fixes this issue.

like image 40
smileyborg Avatar answered Sep 28 '22 08:09

smileyborg