修复ios7 uitableviewcell 编辑状态下 删除按钮被覆盖

方法如下:

第一种解决办法:

01// Fix for iOS7, when backgroundView comes above "delete" button

02- (void)willTransitionToState:(UITableViewCellStateMask)state {

03    [super willTransitionToState:state];

04    [self sendSubviewToBack:self.backgroundView];

05    dispatch_async(dispatch_get_main_queue(), ^{

06        [self sendSubviewToBack:self.backgroundView];

07    });

08}

09 

10- (void)didTransitionToState:(UITableViewCellStateMask)state {11    [super didTransitionToState:state];

12    [self sendSubviewToBack:self.backgroundView];

13}

第二种解决办法:

01- (void)layoutSubviews

02{

03    [super layoutSubviews];

04 

05    for (UIView *subview in self.subviews) {

06

 07       

 for (UIView *subview2 in subview.subviews) {

08 

09            if ([NSStringFromClass([subview2 class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) { // move delete confirmation view

10

 11            [subview bringSubviewToFront:subview2];12 13        }14    }15}

第三种解决办法(个人感觉比较简洁):

- (void)layoutSubviews{

   [super layoutSubviews];

         if (self.isEditing) {        

        [self sendSubviewToBack:self.contentView];

        }

}

第四种解决办法:

1- (void) layoutSubviews {

2    [super layoutSubviews];

3

4    if ([ [ [UIDevice currentDevice] systemVersion] compare: @"7.0" options: NSNumericSearch] != NSOrderedAscending) {

5        if (iOS7 == YES) {

6            self.backgroundView.frame = CGRectMake(0, self.backgroundView.frame.origin.y,

7                                                   self.backgroundView.frame.size.width, self.backgroundView.frame.size.height);

8    }

9}

你可能感兴趣的:(修复ios7 uitableviewcell 编辑状态下 删除按钮被覆盖)