|
@@ -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;
|