summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-08-08 17:33:11 +0200
committerTor Andersson <tor.andersson@artifex.com>2012-08-08 17:50:33 +0200
commitf1e46f452b8825859398c11788aafe7f469e846e (patch)
tree5fd008cf82b7f79c4b5e8115123913255870bc4e /ios
parentfbb151fac52da10c3d9bbdfddae98c8ed3affd9d (diff)
downloadmupdf-f1e46f452b8825859398c11788aafe7f469e846e.tar.xz
ios: use viewWillLayoutSubviews instead of layout out only after rotation.
Handle the case where if the device is rotated while showing the outline view, popping back to the document view would show the pages using the old rotation layout.
Diffstat (limited to 'ios')
-rw-r--r--ios/main.m65
1 files changed, 29 insertions, 36 deletions
diff --git a/ios/main.m b/ios/main.m
index 6f2c3b9c..70cd3712 100644
--- a/ios/main.m
+++ b/ios/main.m
@@ -1053,16 +1053,23 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize,
- (void) viewWillAppear: (BOOL)animated
{
- CGSize size = [canvas frame].size;
- width = size.width;
- height = size.height;
-
[self setTitle: [key lastPathComponent]];
[slider setValue: current];
[indicator setText: [NSString stringWithFormat: @" %d of %d ", current+1, count_pages(doc)]];
+ [[self navigationController] setToolbarHidden: NO animated: animated];
+}
+
+- (void) viewWillLayoutSubviews
+{
+ CGSize size = [canvas frame].size;
+ int max_width = MAX(width, size.width);
+
+ width = size.width;
+ height = size.height;
+
[canvas setContentInset: UIEdgeInsetsZero];
[canvas setContentSize: CGSizeMake(count_pages(doc) * width, height)];
[canvas setContentOffset: CGPointMake(current * width, 0)];
@@ -1070,7 +1077,24 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize,
[sliderWrapper setWidth: SLIDER_W];
[searchBar setFrame: CGRectMake(0,0,SEARCH_W,32)];
- [[self navigationController] setToolbarHidden: NO animated: animated];
+ [[[self navigationController] toolbar] setNeedsLayout]; // force layout!
+
+ // use max_width so we don't clamp the content offset too early during animation
+ [canvas setContentSize: CGSizeMake(count_pages(doc) * max_width, height)];
+ [canvas setContentOffset: CGPointMake(current * width, 0)];
+
+ for (MuPageView *view in [canvas subviews]) {
+ if ([view number] == current) {
+ [view setFrame: CGRectMake([view number] * width, 0, width-GAP, height)];
+ [view willRotate];
+ }
+ }
+ for (MuPageView *view in [canvas subviews]) {
+ if ([view number] != current) {
+ [view setFrame: CGRectMake([view number] * width, 0, width-GAP, height)];
+ [view willRotate];
+ }
+ }
}
- (void) viewDidAppear: (BOOL)animated
@@ -1401,37 +1425,6 @@ static UIImage *renderTile(struct document *doc, int number, CGSize screenSize,
return YES;
}
-- (void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
-{
- CGSize size = [canvas frame].size;
- int max_width = MAX(width, size.width);
-
- width = size.width;
- height = size.height;
-
- [sliderWrapper setWidth: SLIDER_W];
- [searchBar setFrame: CGRectMake(0,0,SEARCH_W,32)];
-
- [[[self navigationController] toolbar] setNeedsLayout]; // force layout!
-
- // use max_width so we don't clamp the content offset too early during animation
- [canvas setContentSize: CGSizeMake(count_pages(doc) * max_width, height)];
- [canvas setContentOffset: CGPointMake(current * width, 0)];
-
- for (MuPageView *view in [canvas subviews]) {
- if ([view number] == current) {
- [view setFrame: CGRectMake([view number] * width, 0, width-GAP, height)];
- [view willRotate];
- }
- }
- for (MuPageView *view in [canvas subviews]) {
- if ([view number] != current) {
- [view setFrame: CGRectMake([view number] * width, 0, width-GAP, height)];
- [view willRotate];
- }
- }
-}
-
- (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation)o
{
[canvas setContentSize: CGSizeMake(count_pages(doc) * width, height)];