Browse Source

解决iOS12系统上cell上button不显示问题

heavyrain2012 4 years ago
parent
commit
02ec0f92e4

+ 5 - 1
wfchat/WildFireChat/Me/WFCSettingTableViewController.m

@@ -237,7 +237,11 @@
         [btn setTitleColor:[UIColor colorWithHexString:@"0xf95569"]
                   forState:UIControlStateNormal];
         [btn addTarget:self action:@selector(onLogoutBtn:) forControlEvents:UIControlEventTouchUpInside];
-        [cell.contentView addSubview:btn];
+        if (@available(iOS 14, *)) {
+            [cell.contentView addSubview:btn];
+        } else {
+            [cell addSubview:btn];
+        }
     }
     
     return cell;

+ 20 - 4
wfuikit/WFChatUIKit/CommonVC/WFCUProfileTableViewController.m

@@ -253,7 +253,11 @@
         momentButton.titleLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
         momentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
         [momentButton addTarget:self action:@selector(momentClick) forControlEvents:UIControlEventTouchUpInside];
-        [self.momentCell.contentView addSubview:momentButton];
+        if (@available(iOS 14, *)) {
+            [self.momentCell.contentView addSubview:momentButton];
+        } else {
+            [self.momentCell addSubview:momentButton];
+        }
         self.momentCell.selectionStyle = UITableViewCellSelectionStyleNone;
         self.momentCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
     }
@@ -270,7 +274,11 @@
         [btn setTitleColor:[WFCUConfigManager globalManager].textColor forState:UIControlStateNormal];
         btn.titleLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleMedium size:16];
         [btn addTarget:self action:@selector(onSendMessageBtn:) forControlEvents:UIControlEventTouchDown];
-        [self.sendMessageCell.contentView addSubview:btn];
+        if (@available(iOS 14, *)) {
+            [self.sendMessageCell.contentView addSubview:btn];
+        } else {
+            [self.sendMessageCell addSubview:btn];
+        }
         [self showSeparatorLine:self.sendMessageCell];
         
 #if WFCU_SUPPORT_VOIP
@@ -285,7 +293,11 @@
         [btn addTarget:self action:@selector(onVoipCallBtn:) forControlEvents:UIControlEventTouchDown];
         [btn setTitleColor:[UIColor colorWithHexString:@"0x5b6e8e"] forState:UIControlStateNormal];
         btn.titleLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleMedium size:16];
-        [self.voipCallCell.contentView addSubview:btn];
+        if (@available(iOS 14, *)) {
+            [self.voipCallCell.contentView addSubview:btn];
+        } else {
+            [self.voipCallCell addSubview:btn];
+        }
 #endif
     } else if([[WFCCNetworkService sharedInstance].userId isEqualToString:self.userId]) {
         
@@ -300,7 +312,11 @@
         [btn addTarget:self action:@selector(onAddFriendBtn:) forControlEvents:UIControlEventTouchDown];
         btn.layer.cornerRadius = 5.f;
         btn.layer.masksToBounds = YES;
-        [self.addFriendCell.contentView addSubview:btn];
+        if (@available(iOS 14, *)) {
+            [self.addFriendCell.contentView addSubview:btn];
+        } else {
+            [self.addFriendCell addSubview:btn];
+        }
         
     }
     [self.tableView reloadData];

+ 15 - 3
wfuikit/WFChatUIKit/ConversationSetting/ViewController/WFCUConversationSettingViewController.m

@@ -664,7 +664,11 @@
           btn.titleLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
           [btn setTitleColor:[UIColor colorWithHexString:@"0xf95569"] forState:UIControlStateNormal];
           [btn addTarget:self action:@selector(clearMessageAction) forControlEvents:UIControlEventTouchUpInside];
-          [cell.contentView addSubview:btn];
+          if (@available(iOS 14, *)) {
+              [cell.contentView addSubview:btn];
+          } else {
+              [cell addSubview:btn];
+          }
       }
       return cell;
   } else if([self isQuitGroup:indexPath]) {
@@ -683,7 +687,11 @@
             btn.titleLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
             [btn setTitleColor:[UIColor colorWithHexString:@"0xf95569"] forState:UIControlStateNormal];
             [btn addTarget:self action:@selector(onDeleteAndQuit:) forControlEvents:UIControlEventTouchUpInside];
-            [cell.contentView addSubview:btn];
+            if (@available(iOS 14, *)) {
+                [cell.contentView addSubview:btn];
+            } else {
+                [cell addSubview:btn];
+            }
         }
         return cell;
   } else if([self isUnsubscribeChannel:indexPath]) {
@@ -705,7 +713,11 @@
           
           btn.backgroundColor = [UIColor redColor];
           [btn addTarget:self action:@selector(onDeleteAndQuit:) forControlEvents:UIControlEventTouchUpInside];
-          [cell.contentView addSubview:btn];
+          if (@available(iOS 14, *)) {
+              [cell.contentView addSubview:btn];
+          } else {
+              [cell addSubview:btn];
+          }
       }
       return cell;
   } else if([self isGroupFileCell:indexPath]) {