Permalink
Browse files

Version 2.1.1

  • Loading branch information...
1 parent 56ce386 commit 17c635c83561de10077c9188b96498e906a6054c @vfr vfr committed Aug 27, 2011
Showing with 83 additions and 47 deletions.
  1. +12 −7 README
  2. +1 −1 Reader-Info.plist
  3. +5 −3 Sources/ReaderContentPage.m
  4. +3 −1 Sources/ReaderViewController.h
  5. +62 −35 Sources/ReaderViewController.m
View
@@ -47,13 +47,14 @@ uses the ReaderDocument object to store information about the
document and to keep track of document properties (the current
page number for example).
-An initialized ReaderViewController can then be presented modally,
-pushed onto a UINavigationController stack, or used as a root view
-controller. Please note that since ReaderViewController implements
-its own toolbar, you need to hide the UINavigationController's
-navigation bar before pushing it and then show the navigation
-bar after popping it. The ReaderDemoController class shows how
-this is done with a bundled PDF file.
+An initialized ReaderViewController can then be presented
+modally, pushed onto a UINavigationController stack, placed in
+a UITabBarController tab, or be used as a root view controller.
+Please note that since ReaderViewController implements its own
+toolbar, you need to hide the UINavigationController navigation
+bar before pushing it and then show the navigation bar after
+popping it. The ReaderDemoController class shows how this is
+done with a bundled PDF file.
Required Files
--------------
@@ -126,6 +127,10 @@ HISTORY
- Added PDF link (URI and page target) support.
+2011-08-27: Version 2.1.1
+
+ - Fixed rotation handling when in a UITabBarController.
+
CONTACT INFO
Questions, feedback and iOS development work welcome:
View
@@ -25,7 +25,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>2.1.0</string>
+ <string>2.1.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIPrerenderedIcon</key>
@@ -1,6 +1,6 @@
//
// ReaderContentPage.m
-// Reader v2.1.0
+// Reader v2.1.1
//
// Created by Julius Oklamcak on 2011-07-01.
// Copyright © 2011 Julius Oklamcak. All rights reserved.
@@ -550,13 +550,15 @@ - (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context
//CGContextFillRect(context, CGContextGetClipBoundingBox(context)); // Fill
- if (drawPDFPageRef != NULL) // Go ahead and draw the PDF page into the context
+ if (drawPDFPageRef != NULL) // Go ahead and render the PDF page into the context
{
CGContextTranslateCTM(context, 0.0f, self.bounds.size.height); CGContextScaleCTM(context, 1.0f, -1.0f);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(drawPDFPageRef, kCGPDFCropBox, self.bounds, 0, true));
- CGContextDrawPDFPage(context, drawPDFPageRef); // Draw the PDF page into the context
+ CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); CGContextSetInterpolationQuality(context, kCGInterpolationDefault);
+
+ CGContextDrawPDFPage(context, drawPDFPageRef); // Render the PDF page into the context
}
CGPDFPageRelease(drawPDFPageRef); CGPDFDocumentRelease(drawPDFDocRef); // Cleanup
@@ -1,6 +1,6 @@
//
// ReaderViewController.h
-// Reader v2.0.0
+// Reader v2.1.1
//
// Created by Julius Oklamcak on 2011-07-01.
// Copyright © 2011 Julius Oklamcak. All rights reserved.
@@ -51,6 +51,8 @@
NSInteger currentPage;
+ CGSize lastAppearSize;
+
NSDate *lastHideTime;
BOOL isVisible;
@@ -1,6 +1,6 @@
//
// ReaderViewController.m
-// Reader v2.1.0
+// Reader v2.1.1
//
// Created by Julius Oklamcak on 2011-07-01.
// Copyright © 2011 Julius Oklamcak. All rights reserved.
@@ -34,6 +34,10 @@ @implementation ReaderViewController
- (void)updateScrollViewContentSize
{
+#ifdef DEBUGX
+ NSLog(@"%s", __FUNCTION__);
+#endif
+
NSInteger count = [document.pageCount integerValue];
if (count > PAGING_VIEWS) count = PAGING_VIEWS; // Limit
@@ -45,6 +49,48 @@ - (void)updateScrollViewContentSize
theScrollView.contentSize = CGSizeMake(contentWidth, contentHeight);
}
+- (void)updateScrollViewContentViews
+{
+#ifdef DEBUGX
+ NSLog(@"%s", __FUNCTION__);
+#endif
+
+ [self updateScrollViewContentSize]; // Update the content size
+
+ NSMutableIndexSet *pageSet = [[NSMutableIndexSet new] autorelease];
+
+ [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views
+ ^(id key, id object, BOOL *stop)
+ {
+ ReaderContentView *contentView = object;
+
+ [pageSet addIndex:contentView.tag];
+ }
+ ];
+
+ __block CGRect viewRect = CGRectZero; viewRect.size = theScrollView.bounds.size;
+
+ __block CGPoint contentOffset = CGPointZero; NSInteger page = [document.pageNumber integerValue];
+
+ [pageSet enumerateIndexesUsingBlock: // Enumerate page number set
+ ^(NSUInteger number, BOOL *stop)
+ {
+ NSNumber *key = [NSNumber numberWithInteger:number]; // # key
+
+ ReaderContentView *contentView = [contentViews objectForKey:key];
+
+ contentView.frame = viewRect; if (page == number) contentOffset = viewRect.origin;
+
+ viewRect.origin.x += viewRect.size.width; // Next view frame position
+ }
+ ];
+
+ if (CGPointEqualToPoint(theScrollView.contentOffset, contentOffset) == false)
+ {
+ theScrollView.contentOffset = contentOffset; // Update content offset
+ }
+}
+
- (void)showDocumentPage:(NSInteger)page
{
#ifdef DEBUGX
@@ -283,6 +329,16 @@ - (void)viewWillAppear:(BOOL)animated
#endif
[super viewWillAppear:animated];
+
+ if (CGSizeEqualToSize(lastAppearSize, CGSizeZero) == false)
+ {
+ if (CGSizeEqualToSize(lastAppearSize, self.view.bounds.size) == false)
+ {
+ [self updateScrollViewContentViews]; // Update content views
+ }
+
+ lastAppearSize = CGSizeZero; // Reset view size tracking
+ }
}
- (void)viewDidAppear:(BOOL)animated
@@ -313,6 +369,8 @@ - (void)viewWillDisappear:(BOOL)animated
[super viewWillDisappear:animated];
+ lastAppearSize = self.view.bounds.size; // Track view size
+
#if (READER_DISABLE_IDLE == TRUE) // Option
[UIApplication sharedApplication].idleTimerDisabled = NO;
@@ -339,7 +397,7 @@ - (void)viewDidUnload
[theScrollView release], theScrollView = nil; [contentViews release], contentViews = nil;
- [lastHideTime release], lastHideTime = nil; currentPage = 0;
+ [lastHideTime release], lastHideTime = nil; lastAppearSize = CGSizeZero; currentPage = 0;
[super viewDidUnload];
}
@@ -372,40 +430,9 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interf
if (isVisible == NO) return; // iOS present modal WTF bodge
- [self updateScrollViewContentSize]; // Update the content size
-
- NSMutableIndexSet *pageSet = [[NSMutableIndexSet new] autorelease];
-
- [contentViews enumerateKeysAndObjectsUsingBlock: // Enumerate content views
- ^(id key, id object, BOOL *stop)
- {
- ReaderContentView *contentView = object;
-
- [pageSet addIndex:contentView.tag];
- }
- ];
-
- __block CGRect viewRect = CGRectZero; viewRect.size = theScrollView.bounds.size;
-
- __block CGPoint contentOffset = CGPointZero; NSInteger page = [document.pageNumber integerValue];
-
- [pageSet enumerateIndexesUsingBlock: // Enumerate page number set
- ^(NSUInteger number, BOOL *stop)
- {
- NSNumber *key = [NSNumber numberWithInteger:number]; // # key
-
- ReaderContentView *contentView = [contentViews objectForKey:key];
+ [self updateScrollViewContentViews]; // Update content views
- contentView.frame = viewRect; if (page == number) contentOffset = viewRect.origin;
-
- viewRect.origin.x += viewRect.size.width; // Next view frame position
- }
- ];
-
- if (CGPointEqualToPoint(theScrollView.contentOffset, contentOffset) == false)
- {
- theScrollView.contentOffset = contentOffset; // Update content offset
- }
+ lastAppearSize = CGSizeZero; // Reset view size tracking
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

0 comments on commit 17c635c

Please sign in to comment.