Parcourir la source

修改检查系统版本的方法,移除 @available 关键字

Russell il y a 8 ans
Parent
commit
1db7917752

+ 8 - 5
MJRefresh/UIScrollView+MJExtension.m

@@ -10,12 +10,15 @@
 #import "UIScrollView+MJExtension.h"
 #import <objc/runtime.h>
 
+#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
+
+
 @implementation UIScrollView (MJExtension)
 
 - (UIEdgeInsets)mj_inset
 {
 #ifdef __IPHONE_11_0
-    if(@available(iOS 11.0, *)){
+    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
         return self.adjustedContentInset;
     }
 #endif
@@ -27,7 +30,7 @@ - (void)setMj_insetT:(CGFloat)mj_insetT
     UIEdgeInsets inset = self.contentInset;
     inset.top = mj_insetT;
 #ifdef __IPHONE_11_0
-    if(@available(iOS 11.0, *)){
+    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
         inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
     }
 #endif
@@ -44,7 +47,7 @@ - (void)setMj_insetB:(CGFloat)mj_insetB
     UIEdgeInsets inset = self.contentInset;
     inset.bottom = mj_insetB;
 #ifdef __IPHONE_11_0
-    if(@available(iOS 11.0, *)){
+    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
         inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom);
     }
 #endif
@@ -61,7 +64,7 @@ - (void)setMj_insetL:(CGFloat)mj_insetL
     UIEdgeInsets inset = self.contentInset;
     inset.left = mj_insetL;
 #ifdef __IPHONE_11_0
-    if(@available(iOS 11.0, *)){
+    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
         inset.left -= (self.adjustedContentInset.left - self.contentInset.left);
     }
 #endif
@@ -78,7 +81,7 @@ - (void)setMj_insetR:(CGFloat)mj_insetR
     UIEdgeInsets inset = self.contentInset;
     inset.right = mj_insetR;
 #ifdef __IPHONE_11_0
-    if(@available(iOS 11.0, *)){
+    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"11.0")) {
         inset.right -= (self.adjustedContentInset.right - self.contentInset.right);
     }
 #endif

+ 3 - 3
MJRefreshExample.xcodeproj/xcshareddata/xcschemes/MJRefreshFramework.xcscheme

@@ -15,7 +15,7 @@
             <BuildableReference
                BuildableIdentifier = "primary"
                BlueprintIdentifier = "2D9DF4511F7CE29B0042D6DD"
-               BuildableName = "MJRefreshFramework.framework"
+               BuildableName = "MJRefresh.framework"
                BlueprintName = "MJRefreshFramework"
                ReferencedContainer = "container:MJRefreshExample.xcodeproj">
             </BuildableReference>
@@ -48,7 +48,7 @@
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "2D9DF4511F7CE29B0042D6DD"
-            BuildableName = "MJRefreshFramework.framework"
+            BuildableName = "MJRefresh.framework"
             BlueprintName = "MJRefreshFramework"
             ReferencedContainer = "container:MJRefreshExample.xcodeproj">
          </BuildableReference>
@@ -66,7 +66,7 @@
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "2D9DF4511F7CE29B0042D6DD"
-            BuildableName = "MJRefreshFramework.framework"
+            BuildableName = "MJRefresh.framework"
             BlueprintName = "MJRefreshFramework"
             ReferencedContainer = "container:MJRefreshExample.xcodeproj">
          </BuildableReference>