apple преди 7 години
родител
ревизия
08ef58a689

BIN
ios/JianYuIOS/JianYuIOS.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 2
ios/JianYuIOS/JianYuIOS/Base.lproj/Main.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -44,6 +44,7 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
             </objects>
+            <point key="canvasLocation" x="7" y="109"/>
         </scene>
     </scenes>
 </document>

+ 86 - 12
ios/JianYuIOS/JianYuIOS/ViewController.m

@@ -18,6 +18,7 @@
 
 
 
+#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
 
 @protocol ViewControllerMain<JSExport>
 
@@ -49,12 +50,15 @@ JSExportAs(alert, -(void)jsAlert:(NSString *)content);// 弹框
 JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否安装微信
 
 
-
 @end
 
 
 
 @interface ViewController ()<UIWebViewDelegate, ViewControllerJSExport>
+{
+    CGPoint startTouch;
+    BOOL _isMoving;
+}
 
 @property (weak, nonatomic) IBOutlet UIWebView *webView;
 //@property(nonatomic, assign)BOOL ;
@@ -68,15 +72,23 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
 
 
 
+
 @end
 
 @implementation ViewController
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-        
+    
     [LXDataBaseManager shareDataBaseManager];
     if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {
+//        if(KIsiPhoneX) {
+//            self.topC.constant = -44;
+//            [self.webView updateConstraints];
+//        }else {
+//            self.topC.constant = -20;
+//            [self.webView updateConstraints];
+//        }
         self.topC.constant = -20;
         [self.webView updateConstraints];
     }
@@ -93,19 +105,81 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
     [[AFNetworkReachabilityManager sharedManager] startMonitoring];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
     
-//   int state =  [[[NSUserDefaults standardUserDefaults] objectForKey:@"firstLoad"] intValue];
-//    AFNetworkingReachabilityDidChangeNotification
+//    [self clearWeb];
+
+    UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
+    [recognizer delaysTouchesBegan];
+    [self.view addGestureRecognizer:recognizer];
+}
+
+-(void)moveViewWithX:(float)x
+{
+    CGRect rect = self.view.bounds;
+    CGFloat width = CGRectGetWidth(rect);
+    x = x>width?width:x;
+    x = x<0?0:x;
+    CGRect frame = self.webView.frame;
+    frame.origin.x = x;
+    self.webView.frame = frame;
+}
+
+#pragma mark – Gesture Recognizer –
+-(void)paningGestureReceive:(UIPanGestureRecognizer *)recoginzer
+{
+    CGRect rect = self.view.bounds;
+    CGFloat width = CGRectGetWidth(rect);
+    if (![self.webView canGoBack]) {
+        NSLog(@"不可返回");
+        return;
+    }
     
-//    if (state != 1) {
-//         if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable) {
-//             [self noNetGetData];
-//         }else{
-//             [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"firstLoad"];
-//         }
-//    }
-    [self clearWeb];
+    NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
+    NSLog(@"当前页面:%@",current_url);
+//    NSString *current_url = self.webView.request.URL.absoluteString;
+    if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
+        return;
+    }
+
+    //https://www.jianyu360.com/jyapp/free/me
+    //https://www.jianyu360.com/jyapp/jylab/index
+    //https://www.jianyu360.com/jyapp/wxkeyset/keyset/index
+    //https://www.jianyu360.com/jyapp/jylab/mainSearch
+    
+    CGPoint touchPoint = [recoginzer locationInView:[UIApplication sharedApplication].keyWindow];
+    if (recoginzer.state==UIGestureRecognizerStateBegan) {
+        _isMoving = YES;
+        startTouch = touchPoint;
+    } else if (recoginzer.state==UIGestureRecognizerStateEnded){
+        if (touchPoint.x - startTouch.x > width*0.125) {
+            [UIView animateWithDuration:0.3 animations:^{
+                [self moveViewWithX:width];
+                [self.webView goBack];
+            } completion:^(BOOL finished) {
+                _isMoving = NO;
+                [self moveViewWithX:0];
+            }];
+        } else {
+            [UIView animateWithDuration:0.3 animations:^{
+                [self moveViewWithX:0];
+            } completion:^(BOOL finished) {
+                _isMoving = NO;
+            }];
+        }
+        return;
+    } else if (recoginzer.state==UIGestureRecognizerStateCancelled){
+        [UIView animateWithDuration:0.3 animations:^{
+            [self moveViewWithX:0];
+        } completion:^(BOOL finished) {
+            _isMoving = NO;
+        }];
+        return;
+    }
+    if (_isMoving) {
+        [self moveViewWithX:touchPoint.x - startTouch.x];
+    }
 }
 
+
 // 监控网络状态变化
 -(void)netReachChanged:(NSNotification *)notificaition{
     NSDictionary *userInfo = notificaition.userInfo;