|
@@ -22,9 +22,19 @@
|
|
|
|
|
|
|
|
#import "RAUtils.h"
|
|
#import "RAUtils.h"
|
|
|
|
|
|
|
|
|
|
+typedef enum {
|
|
|
|
|
+ ScreenOrientationUnknown = 0,
|
|
|
|
|
+ ScreenOrientationPortrait = 1,
|
|
|
|
|
+ ScreenOrientationLand = 3
|
|
|
|
|
+}ScreenOrientation;
|
|
|
|
|
+
|
|
|
//#import "TouchImageView.h"
|
|
//#import "TouchImageView.h"
|
|
|
@interface PageViewController ()
|
|
@interface PageViewController ()
|
|
|
|
|
|
|
|
|
|
+@property (nonatomic,assign) ScreenOrientation orientation;
|
|
|
|
|
+@property (nonatomic,assign) ScreenOrientation currentAppOrientation;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation PageViewController
|
|
@implementation PageViewController
|
|
@@ -46,11 +56,16 @@
|
|
|
// [menu setMenuVisible:YES animated:YES];
|
|
// [menu setMenuVisible:YES animated:YES];
|
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
|
|
+- (ScreenOrientation)currentAppOrientation {
|
|
|
|
|
+ CGSize screenSize = [UIScreen mainScreen].bounds.size;
|
|
|
|
|
+ if (screenSize.width > screenSize.height) return ScreenOrientationLand;
|
|
|
|
|
+ return ScreenOrientationPortrait;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
- (void)viewDidLoad {
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-//
|
|
|
|
|
|
|
+//
|
|
|
// self.pdfScrollView = [[PDFScrollView alloc]initWithFrame:CGRectMake(0, 64, 768, 960)];
|
|
// self.pdfScrollView = [[PDFScrollView alloc]initWithFrame:CGRectMake(0, 64, 768, 960)];
|
|
|
// self.pdfScrollView.backgroundColor= [UIColor redColor];
|
|
// self.pdfScrollView.backgroundColor= [UIColor redColor];
|
|
|
|
|
|
|
@@ -62,8 +77,8 @@
|
|
|
|
|
|
|
|
self.pdfScrollView.contentSize = self.pdfScrollView.frame.size;
|
|
self.pdfScrollView.contentSize = self.pdfScrollView.frame.size;
|
|
|
self.keyboard_h=0;
|
|
self.keyboard_h=0;
|
|
|
-
|
|
|
|
|
- [self initControl];
|
|
|
|
|
|
|
+// self.pdfScrollView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
|
|
|
|
|
+// [self initControl];
|
|
|
|
|
|
|
|
// UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc]
|
|
// UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc]
|
|
|
// initWithTarget:self
|
|
// initWithTarget:self
|
|
@@ -72,6 +87,16 @@
|
|
|
// [self.view addGestureRecognizer:pinchGestureRecognizer];
|
|
// [self.view addGestureRecognizer:pinchGestureRecognizer];
|
|
|
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
// 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
|
|
-(void)viewWillAppear:(BOOL)animated
|
|
|
{
|
|
{
|
|
@@ -88,14 +113,87 @@
|
|
|
|
|
|
|
|
// self.pdfScrollView.contentSize = self.pdfScrollView.frame.size;
|
|
// 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
|
|
-(void) viewWillDisappear:(BOOL)animated
|
|
|
{
|
|
{
|
|
|
[self.hotTextView endEditing:true];
|
|
[self.hotTextView endEditing:true];
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
-
|
|
|
|
|
|
|
+ self.orientation = self.currentAppOrientation;
|
|
|
}
|
|
}
|
|
|
-(void) dealloc
|
|
-(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");
|
|
|
|
|
+// // }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|