ソースを参照

1.修复Edit PDF界面在屏幕旋转后视图存在偏差。
2.修改心跳包,登录后在连不上服务器时不处理超时。

Pen Li 9 年 前
コミット
3f48faa02d

BIN
Ants Contract/AntsContract.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 3
Ants Contract/AntsContract/AntsContract/Base.lproj/Main.storyboard

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES" initialViewController="UmP-Fl-ZUI">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16A323" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES" initialViewController="UmP-Fl-ZUI">
     <device id="ipad9_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -152,7 +152,7 @@
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" maximumZoomScale="3" id="UZY-AP-7MO" customClass="PDFScrollView">
+                            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" maximumZoomScale="3" id="UZY-AP-7MO" customClass="PDFScrollView">
                                 <rect key="frame" x="0.0" y="64" width="768" height="960"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <subviews>

+ 23 - 4
Ants Contract/common/AppDelegate.m

@@ -57,6 +57,8 @@
     
     if(self.bLogin)
     {
+        [self checkSelfWindowIsKeyWindow];
+        
         UINavigationController *rootVC = (UINavigationController *)application.keyWindow.rootViewController;
         
         UIViewController* presentVC=rootVC.presentedViewController;
@@ -117,7 +119,7 @@
     {
         self.shareFile = item;
         
-        
+        [self checkSelfWindowIsKeyWindow];
         
         UINavigationController *rootVC = (UINavigationController *)application.keyWindow.rootViewController;
         
@@ -385,6 +387,22 @@
     }
 }
 
+- (void)checkSelfWindowIsKeyWindow {
+    UIApplication *application = [UIApplication sharedApplication];
+    
+    if (![self.window isEqual:application.keyWindow]) {
+        UIWindow *window = application.keyWindow;
+        [window resignKeyWindow];
+        if (window.superview) {
+            [window removeFromSuperview];
+        }
+        window.hidden = YES;
+        window = nil;
+        
+        [self.window makeKeyWindow];
+    }
+
+}
 
 - (void)heartBeatTimeout {
     __weak typeof(self) weakself = self;
@@ -405,13 +423,13 @@
             window.hidden = YES;
             window = nil;
             
-            [self.window makeKeyWindow];
+            [weakself.window makeKeyWindow];
         }
         
         UINavigationController *rootVC = (UINavigationController *)application.keyWindow.rootViewController;
         // 提示登录
         UIViewController* presentVC=rootVC.presentedViewController;
-        if (presentVC) { //如果当前已有模态对话框,则关闭当前的模态框
+        if (presentVC && ![presentVC isKindOfClass:[LoginViewController class]]) { //如果当前已有非Login模态对话框,则关闭当前的模态框
             [presentVC dismissViewControllerAnimated:NO completion:^{
                 // 退回到初始视图
 //                [rootVC popToRootViewControllerAnimated:NO];
@@ -465,7 +483,8 @@
             
         } else if ([weakself checkHearBeatTimeOut]) {// 本地检查超时(上一次成功心跳距现在的间隔时间超出1h)
         
-            [weakself heartBeatTimeout];
+            // 本地不检查超时!!!不能知道后台设置的超时时长
+//            [weakself heartBeatTimeout];
         }
         
         NSLog(@"heart beat result %d",result);

+ 121 - 22
Ants Contract/common/PageViewController.m

@@ -22,9 +22,19 @@
 
 #import "RAUtils.h"
 
+typedef enum {
+    ScreenOrientationUnknown = 0,
+    ScreenOrientationPortrait = 1,
+    ScreenOrientationLand = 3
+}ScreenOrientation;
+
 //#import "TouchImageView.h"
 @interface PageViewController ()
 
+@property (nonatomic,assign) ScreenOrientation orientation;
+@property (nonatomic,assign) ScreenOrientation currentAppOrientation;
+
+
 @end
 
 @implementation PageViewController
@@ -46,11 +56,16 @@
 //    [menu setMenuVisible:YES animated:YES];
 //}
 
+- (ScreenOrientation)currentAppOrientation {
+    CGSize screenSize = [UIScreen mainScreen].bounds.size;
+    if (screenSize.width > screenSize.height) return ScreenOrientationLand;
+    return ScreenOrientationPortrait;
+}
+
 - (void)viewDidLoad {
     [super viewDidLoad];
 
-    
-//    
+//
 //    self.pdfScrollView = [[PDFScrollView alloc]initWithFrame:CGRectMake(0, 64, 768, 960)];
 //    self.pdfScrollView.backgroundColor= [UIColor redColor];
     
@@ -62,8 +77,8 @@
     
     self.pdfScrollView.contentSize = self.pdfScrollView.frame.size;
     self.keyboard_h=0;
-    
-    [self initControl];
+//    self.pdfScrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
+//    [self initControl];
     
     //    UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc]
     //                                                        initWithTarget:self
@@ -72,6 +87,16 @@
     //    [self.view addGestureRecognizer:pinchGestureRecognizer];
     
     // Do any additional setup after loading the view.
+    self.orientation = ScreenOrientationUnknown;
+    
+//    self.pdfScrollView.backgroundColor = [UIColor redColor];
+//    [self.pdfScrollView viewWithTag:1024].backgroundColor = [UIColor orangeColor];
+//    self.pdfPageView.backgroundColor = [UIColor yellowColor];
+//    self.editControlView.backgroundColor = [UIColor colorWithRed:0.4 green:0.8 blue:0.3 alpha:0.5];
+//
+//    [self.pdfPageView removeFromSuperview];
+//    [self.editControlView removeFromSuperview];
+    
 }
 -(void)viewWillAppear:(BOOL)animated
 {
@@ -88,14 +113,87 @@
     
 //    self.pdfScrollView.contentSize = self.pdfScrollView.frame.size;
    
-    [self refreshControl];
+    
+    
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+    if (self.orientation != ScreenOrientationUnknown) {
+        if (self.orientation == self.currentAppOrientation) {
+            [self refreshControl];
+        } else {
+            [self rotateView];
+        }
+    } else {
+        [self initControl];
+    }
+}
+
+- (void)rotateView {
+    
+    for (UIView * v in self.editControlView.subviews)
+    {
+        [v removeFromSuperview ];
+    }
+    
+    self.pdfScrollView.scrollEnabled = NO;
+    // root
+    [self updateView:self.view];
+    
+    // scroll
+    [self updateView:self.pdfScrollView];
+    
+    // 1024 view
+    [self updateView:[self.pdfScrollView viewWithTag:1024]];
+    
+    // pdf
+    [self updateView:self.pdfPageView];
+//            NSLog(@"pdf page frame %@",[NSValue valueWithCGRect:self.pdfPageView.frame]);
+    [self.pdfPageView setNeedsDisplay];
+    
+    // edit
+    [self updateView:self.editControlView];
+
+    // contentSize
+    self.pdfScrollView.contentSize = [self.pdfScrollView viewWithTag:1024].bounds.size;
+    self.pdfScrollView.contentOffset = CGPointZero;
+    
+    [self initControl];
+    
+    self.pdfScrollView.scrollEnabled = YES;
+    
+    self.orientation = self.currentAppOrientation;
+}
+
+- (void)updateView:(UIView *)view {
+//    return;
+    if (!view) return;
+    CGRect frame = [UIScreen mainScreen].bounds;
+    
+    if (view == self.view) {
+        
+    } else if (view == self.pdfScrollView) {
+        frame.origin.y = 64;
+        frame.size.height -= 64;
+        self.pdfScrollView.contentSize = CGSizeZero;
+    } else {
+        frame.size.height -= 64;
+        view.transform = CGAffineTransformIdentity; // 解决缩放后,旋转屏幕。产生偏差(ContentSize和ContentOffset)
+    }
+    
+    view.frame = frame;
+    view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
+    
+    [view layoutIfNeeded];
+    [view setNeedsDisplay];
 }
 
 -(void) viewWillDisappear:(BOOL)animated
 {
     [self.hotTextView endEditing:true];
     [[NSNotificationCenter defaultCenter] removeObserver:self];
-
+    self.orientation = self.currentAppOrientation;
 }
 -(void) dealloc
 {
@@ -275,24 +373,25 @@
 {
     
 
+    [self rotateView];
     
 
-    [self initControl];
-//    [self.pdfPageView setNeedsLayout];
-    [self.pdfPageView setNeedsDisplay];
-//    UIDeviceOrientation dev_ori = [[UIDevice currentDevice]orientation];
-    
-//    UIApplication * app = [UIApplication sharedApplication];
-//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-//    [appDelegate didRotated];
-    
-    //    UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
-    //    if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
-    //    {
-    //        self.orientation = orientation;
-    //        [self.collectionview.collectionViewLayout invalidateLayout];
-    //        DebugLog(@"routed");
-    //    }
+//    [self initControl];
+////    [self.pdfPageView setNeedsLayout];
+//    [self.pdfPageView setNeedsDisplay];
+////    UIDeviceOrientation dev_ori = [[UIDevice currentDevice]orientation];
+//    
+////    UIApplication * app = [UIApplication sharedApplication];
+////    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+////    [appDelegate didRotated];
+//    
+//    //    UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
+//    //    if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
+//    //    {
+//    //        self.orientation = orientation;
+//    //        [self.collectionview.collectionViewLayout invalidateLayout];
+//    //        DebugLog(@"routed");
+//    //    }