修復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}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容