Browse Source

修复MJRefresh中UIScrollView (MJExtension) 根据版本对执行代码的判断逻辑

董宝君 7 years ago
parent
commit
e59cff4dc6
1 changed files with 7 additions and 7 deletions
  1. 7 7
      MJRefresh/UIScrollView+MJExtension.m

+ 7 - 7
MJRefresh/UIScrollView+MJExtension.m

@@ -15,17 +15,17 @@
 
 @implementation UIScrollView (MJExtension)
 
-static BOOL gt_ios_11_;
+static BOOL gt_respondsToAdjustedContentInset;
 + (void)load
 {
     // 缓存判断值
-    gt_ios_11_ = ([[[UIDevice currentDevice] systemVersion] compare:@"11" options:NSNumericSearch] != NSOrderedAscending);
+    gt_respondsToAdjustedContentInset = [self respondsToSelector:@selector(adjustedContentInset)];
 }
 
 - (UIEdgeInsets)mj_inset
 {
 #ifdef __IPHONE_11_0
-    if (gt_ios_11_) {
+    if (gt_respondsToAdjustedContentInset) {
         return self.adjustedContentInset;
     }
 #endif
@@ -37,7 +37,7 @@ - (void)setMj_insetT:(CGFloat)mj_insetT
     UIEdgeInsets inset = self.contentInset;
     inset.top = mj_insetT;
 #ifdef __IPHONE_11_0
-    if (gt_ios_11_) {
+    if (gt_respondsToAdjustedContentInset) {
         inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
     }
 #endif
@@ -54,7 +54,7 @@ - (void)setMj_insetB:(CGFloat)mj_insetB
     UIEdgeInsets inset = self.contentInset;
     inset.bottom = mj_insetB;
 #ifdef __IPHONE_11_0
-    if (gt_ios_11_) {
+    if (gt_respondsToAdjustedContentInset) {
         inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom);
     }
 #endif
@@ -71,7 +71,7 @@ - (void)setMj_insetL:(CGFloat)mj_insetL
     UIEdgeInsets inset = self.contentInset;
     inset.left = mj_insetL;
 #ifdef __IPHONE_11_0
-    if (gt_ios_11_) {
+    if (gt_respondsToAdjustedContentInset) {
         inset.left -= (self.adjustedContentInset.left - self.contentInset.left);
     }
 #endif
@@ -88,7 +88,7 @@ - (void)setMj_insetR:(CGFloat)mj_insetR
     UIEdgeInsets inset = self.contentInset;
     inset.right = mj_insetR;
 #ifdef __IPHONE_11_0
-    if (gt_ios_11_) {
+    if (gt_respondsToAdjustedContentInset) {
         inset.right -= (self.adjustedContentInset.right - self.contentInset.right);
     }
 #endif