ソースを参照

1.修改RedAnt Mobile Result界面横屏适配iPhone X。

Pen Li 8 年 前
コミット
6309e900f7

BIN
RedAnt Mobile/RedAnt Mobile.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 4 - 2
RedAnt Mobile/RedAnt Mobile/Base.lproj/Main.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Oh6-Jk-fWH">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Oh6-Jk-fWH">
     <device id="retina4_7" orientation="portrait">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
         <adaptation id="fullscreen"/>
     </device>
     </device>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     </dependencies>
@@ -388,8 +388,10 @@
                     </view>
                     </view>
                     <connections>
                     <connections>
                         <outlet property="h_constraint" destination="h6H-4T-JaL" id="HAp-ey-n8l"/>
                         <outlet property="h_constraint" destination="h6H-4T-JaL" id="HAp-ey-n8l"/>
+                        <outlet property="lead_constraint" destination="ggp-dc-IJi" id="19Q-zH-V8c"/>
                         <outlet property="scrollview" destination="wBM-b0-JRO" id="8vF-OO-ThB"/>
                         <outlet property="scrollview" destination="wBM-b0-JRO" id="8vF-OO-ThB"/>
                         <outlet property="tableview" destination="IdY-hf-Rfp" id="4uF-UP-C5a"/>
                         <outlet property="tableview" destination="IdY-hf-Rfp" id="4uF-UP-C5a"/>
+                        <outlet property="trail_constraint" destination="R38-oj-vRo" id="gOM-iV-GxH"/>
                         <outlet property="w_constraint" destination="Mfg-Vj-d9e" id="WbW-SN-U1a"/>
                         <outlet property="w_constraint" destination="Mfg-Vj-d9e" id="WbW-SN-U1a"/>
                     </connections>
                     </connections>
                 </viewController>
                 </viewController>

+ 24 - 0
RedAnt Mobile/RedAnt Mobile/ResultViewController.m

@@ -26,6 +26,8 @@ static const int delta = 25;
 @property (nonatomic,strong) NSDictionary *params;
 @property (nonatomic,strong) NSDictionary *params;
 @property (weak, nonatomic) IBOutlet NSLayoutConstraint *w_constraint;
 @property (weak, nonatomic) IBOutlet NSLayoutConstraint *w_constraint;
 @property (weak, nonatomic) IBOutlet NSLayoutConstraint *h_constraint;
 @property (weak, nonatomic) IBOutlet NSLayoutConstraint *h_constraint;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *trail_constraint;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *lead_constraint;
 
 
 @end
 @end
 
 
@@ -488,11 +490,33 @@ static const int delta = 25;
 //    self.scrollview.contentSize=self.tableview.frame.size;
 //    self.scrollview.contentSize=self.tableview.frame.size;
     
     
     // auto layout
     // auto layout
+    UIView *v = self.tableview.superview;
     int width=[self.content_layout[@"header"][@"width"] intValue];
     int width=[self.content_layout[@"header"][@"width"] intValue];
     if(width<self.view.frame.size.width)
     if(width<self.view.frame.size.width)
         width=self.view.frame.size.width;
         width=self.view.frame.size.width;
     self.w_constraint.constant = width - CGRectGetWidth(self.view.bounds);
     self.w_constraint.constant = width - CGRectGetWidth(self.view.bounds);
     self.h_constraint.constant = 0;
     self.h_constraint.constant = 0;
+    
+    // 约束修改后立即重新布局
+    [self.view layoutIfNeeded];
+    
+    if (@available(iOS 11.0,*)) {
+        UIEdgeInsets edgeInsets = [self.view safeAreaInsets];
+        CGFloat left = edgeInsets.left;
+        CGFloat right = edgeInsets.right;
+        
+        self.lead_constraint.constant = left;
+        self.trail_constraint.constant = -right;
+        // 约束修改后立即重新布局
+        [self.view layoutIfNeeded];
+        
+        CGSize size = v.bounds.size;
+        size.width += left + right;
+        self.scrollview.contentSize = size;
+//        self.scrollview.contentInset = UIEdgeInsetsMake(0, left, 0, right);
+        
+    }
+    
 }
 }
 
 
 #pragma mark - RefreshDelegate
 #pragma mark - RefreshDelegate