diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index fdbd29f..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.pbxproj -crlf -diff -merge diff --git a/.gitignore b/.gitignore index d676377..edc082c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,15 @@ -# xcode noise +# Xcode build/* *.pbxuser +!default.pbxuser *.mode1v3 - -# old skool -.svn - -# osx noise -.DS_Store +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata profile +*.moved-aside diff --git a/Classes/LeavesAppDelegate.h b/Classes/LeavesAppDelegate.h deleted file mode 100644 index 8bd67da..0000000 --- a/Classes/LeavesAppDelegate.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// LeavesAppDelegate.h -// Leaves -// -// Created by Tom Brow on 4/18/10. -// Copyright Tom Brow 2010. All rights reserved. -// - -#import - -@class LeavesViewController; - -@interface LeavesAppDelegate : NSObject { - UIWindow *window; - UIViewController *viewController; -} - -@property (nonatomic, retain) IBOutlet UIWindow *window; - -@end - diff --git a/Classes/PDFExampleViewController.m b/Classes/PDFExampleViewController.m deleted file mode 100644 index 6142acd..0000000 --- a/Classes/PDFExampleViewController.m +++ /dev/null @@ -1,63 +0,0 @@ - // -// PDFExampleViewController.m -// Leaves -// -// Created by Tom Brow on 4/19/10. -// Copyright 2010 Tom Brow. All rights reserved. -// - -#import "PDFExampleViewController.h" -#import "Utilities.h" - -@implementation PDFExampleViewController - -- (id)init { - if (self = [super init]) { - CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("paper.pdf"), NULL, NULL); - pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); - CFRelease(pdfURL); - } - return self; -} - -- (void)dealloc { - CGPDFDocumentRelease(pdf); - [super dealloc]; -} - -- (void) displayPageNumber:(NSUInteger)pageNumber { - self.navigationItem.title = [NSString stringWithFormat: - @"Page %u of %u", - pageNumber, - CGPDFDocumentGetNumberOfPages(pdf)]; -} - -#pragma mark LeavesViewDelegate methods - -- (void) leavesView:(LeavesView *)leavesView willTurnToPageAtIndex:(NSUInteger)pageIndex { - [self displayPageNumber:pageIndex + 1]; -} - -#pragma mark LeavesViewDataSource methods - -- (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView { - return CGPDFDocumentGetNumberOfPages(pdf); -} - -- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { - CGPDFPageRef page = CGPDFDocumentGetPage(pdf, index + 1); - CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFMediaBox), - CGContextGetClipBoundingBox(ctx)); - CGContextConcatCTM(ctx, transform); - CGContextDrawPDFPage(ctx, page); -} - -#pragma mark UIViewController - -- (void) viewDidLoad { - [super viewDidLoad]; - leavesView.backgroundRendering = YES; - [self displayPageNumber:1]; -} - -@end diff --git a/Leaves/LeavesCache.h b/Leaves/LeavesCache.h index 7ee3e4a..b45f83a 100644 --- a/Leaves/LeavesCache.h +++ b/Leaves/LeavesCache.h @@ -1,28 +1,24 @@ // // LeavesCache.h -// Reader +// Leaves // // Created by Tom Brow on 5/12/10. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Copyright 2010 Tom Brow. All rights reserved. // #import @protocol LeavesViewDataSource; -@interface LeavesCache : NSObject { - NSMutableDictionary *pageCache; - id dataSource; - CGSize pageSize; -} +@interface LeavesCache : NSObject -@property (assign) CGSize pageSize; +@property (nonatomic, assign) CGSize pageSize; @property (assign) id dataSource; -- (id) initWithPageSize:(CGSize)aPageSize; -- (CGImageRef) cachedImageForPageIndex:(NSUInteger)pageIndex; -- (void) precacheImageForPageIndex:(NSUInteger)pageIndex; -- (void) minimizeToPageIndex:(NSUInteger)pageIndex; -- (void) flush; +- (id)initWithPageSize:(CGSize)aPageSize; +- (CGImageRef)cachedImageForPageIndex:(NSUInteger)pageIndex; +- (void)precacheImageForPageIndex:(NSUInteger)pageIndex; +- (void)minimizeToPageIndex:(NSUInteger)pageIndex; +- (void)flush; @end diff --git a/Leaves/LeavesCache.m b/Leaves/LeavesCache.m index c8ba486..01c4012 100644 --- a/Leaves/LeavesCache.m +++ b/Leaves/LeavesCache.m @@ -1,48 +1,53 @@ // // LeavesCache.m -// Reader +// Leaves // // Created by Tom Brow on 5/12/10. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Copyright 2010 Tom Brow. All rights reserved. // #import "LeavesCache.h" #import "LeavesView.h" -@implementation LeavesCache +@interface LeavesCache () + +@property (readonly) NSMutableDictionary *pageCache; -@synthesize dataSource, pageSize; +@end -- (id) initWithPageSize:(CGSize)aPageSize +@implementation LeavesCache + +- (id)initWithPageSize:(CGSize)aPageSize { - if ([super init]) { - pageSize = aPageSize; - pageCache = [[NSMutableDictionary alloc] init]; + if (self = [super init]) { + _pageSize = aPageSize; + _pageCache = [[NSMutableDictionary alloc] init]; } return self; } -- (void) dealloc +- (void)dealloc { - [pageCache release]; + [_pageCache release]; [super dealloc]; } - - -- (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex { +- (CGImageRef)imageForPageIndex:(NSUInteger)pageIndex { + if (CGSizeEqualToSize(self.pageSize, CGSizeZero)) + return NULL; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(NULL, - pageSize.width, - pageSize.height, + self.pageSize.width, + self.pageSize.height, 8, /* bits per component*/ - pageSize.width * 4, /* bytes per row */ + self.pageSize.width * 4, /* bytes per row */ colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); - CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width, pageSize.height)); + CGContextClipToRect(context, CGRectMake(0, 0, self.pageSize.width, self.pageSize.height)); - [dataSource renderPageAtIndex:pageIndex inContext:context]; + [self.dataSource renderPageAtIndex:pageIndex inContext:context]; CGImageRef image = CGBitmapContextCreateImage(context); CGContextRelease(context); @@ -53,52 +58,54 @@ - (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex { return image; } -- (CGImageRef) cachedImageForPageIndex:(NSUInteger)pageIndex { +- (CGImageRef)cachedImageForPageIndex:(NSUInteger)pageIndex { NSNumber *pageIndexNumber = [NSNumber numberWithInt:pageIndex]; UIImage *pageImage; - @synchronized (pageCache) { - pageImage = [pageCache objectForKey:pageIndexNumber]; + @synchronized (self.pageCache) { + pageImage = [self.pageCache objectForKey:pageIndexNumber]; } if (!pageImage) { CGImageRef pageCGImage = [self imageForPageIndex:pageIndex]; - pageImage = [UIImage imageWithCGImage:pageCGImage]; - @synchronized (pageCache) { - [pageCache setObject:pageImage forKey:pageIndexNumber]; - } + if (pageCGImage) { + pageImage = [UIImage imageWithCGImage:pageCGImage]; + @synchronized (self.pageCache) { + [self.pageCache setObject:pageImage forKey:pageIndexNumber]; + } + } } return pageImage.CGImage; } -- (void) precacheImageForPageIndexNumber:(NSNumber *)pageIndexNumber { +- (void)precacheImageForPageIndexNumber:(NSNumber *)pageIndexNumber { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self cachedImageForPageIndex:[pageIndexNumber intValue]]; [pool release]; } -- (void) precacheImageForPageIndex:(NSUInteger)pageIndex { +- (void)precacheImageForPageIndex:(NSUInteger)pageIndex { [self performSelectorInBackground:@selector(precacheImageForPageIndexNumber:) withObject:[NSNumber numberWithInt:pageIndex]]; } -- (void) minimizeToPageIndex:(NSUInteger)pageIndex { +- (void)minimizeToPageIndex:(NSUInteger)pageIndex { /* Uncache all pages except previous, current, and next. */ - @synchronized (pageCache) { - for (NSNumber *key in [pageCache allKeys]) + @synchronized (self.pageCache) { + for (NSNumber *key in [self.pageCache allKeys]) if (ABS([key intValue] - (int)pageIndex) > 2) - [pageCache removeObjectForKey:key]; + [self.pageCache removeObjectForKey:key]; } } -- (void) flush { - @synchronized (pageCache) { - [pageCache removeAllObjects]; +- (void)flush { + @synchronized (self.pageCache) { + [self.pageCache removeAllObjects]; } } #pragma mark accessors -- (void) setPageSize:(CGSize)value { - pageSize = value; +- (void)setPageSize:(CGSize)value { + _pageSize = value; [self flush]; } diff --git a/Leaves/LeavesView.h b/Leaves/LeavesView.h index 709db1f..442767e 100644 --- a/Leaves/LeavesView.h +++ b/Leaves/LeavesView.h @@ -7,80 +7,77 @@ // #import -#import -#import "LeavesCache.h" @protocol LeavesViewDataSource; @protocol LeavesViewDelegate; -@interface LeavesView : UIView { - CALayer *topPage; - CALayer *topPageOverlay; - CAGradientLayer *topPageShadow; - - CALayer *topPageReverse; - CALayer *topPageReverseImage; - CALayer *topPageReverseOverlay; - CAGradientLayer *topPageReverseShading; - - CALayer *bottomPage; - CAGradientLayer *bottomPageShadow; - - CGFloat leafEdge; - NSUInteger currentPageIndex; - NSUInteger numberOfPages; - id delegate; - - CGSize pageSize; - LeavesCache *pageCache; - CGFloat preferredTargetWidth; - BOOL backgroundRendering; - - CGPoint touchBeganPoint; - BOOL touchIsActive; - CGRect nextPageRect, prevPageRect; - BOOL interactionLocked; -} +// This view displays a sequence of pages, one at a time. The user navigates +// forward and backward through the sequence using a page-turn gesture or by +// tapping invisible targets on the left and right margins of the current page. +// +// Pages are non-interactive raster images supplied by a data source that +// conforms to the LeavesViewDataSource protocol. +// +// An optional delegate, conforming to the LeavesViewDelegate protocol, is +// notified when the page is turned. +@interface LeavesView : UIView @property (assign) id dataSource; @property (assign) id delegate; -// the automatically determined width of the interactive areas on either side of the page +// The width of the invisible targets in the left and right margins, which may +// be tapped to turn to the previous and next page respectively. +// +// This value is chosen automatically based on the view's frame unless the +// preferredTargetWidth property is set to a nonzero value. @property (readonly) CGFloat targetWidth; -// set this to a nonzero value to get a targetWidth other than the default -@property (assign) CGFloat preferredTargetWidth; - -// the zero-based index of the page currently being displayed. -@property (assign) NSUInteger currentPageIndex; - -// If backgroundRendering is YES, some pages not currently being displayed will be pre-rendered in background threads. -// The default value is NO. Only set this to YES if your implementation of the data source methods is thread-safe. +// If this is set to a nonzero value, it will override the value chosen +// automatically for targetWidth. +// +// The default value of this property is 0. +@property (nonatomic, assign) CGFloat preferredTargetWidth; + +// The zero-based index of the page currently displayed. The value of this +// property changes when the user turns the page. You may also set this value +// programmatically to jump to a certain page. +@property (nonatomic, assign) NSUInteger currentPageIndex; + +// If this property is set to YES, pages likely to be displayed soon will be +// pre-rendered in a background thread to avoid blocking the main thread when +// the page is turned. Only set this to YES if your implementation of the data +// source methods is thread-safe. +// +// The defaut value of this property is NO. @property (assign) BOOL backgroundRendering; -// refreshes the contents of all pages via the data source methods, much like -[UITableView reloadData] -- (void) reloadData; +// Reload content from the data source. This also resets the currentPageIndex +// property to 0 and jumps to the first page. +- (void)reloadData; @end - @protocol LeavesViewDataSource -- (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView; -- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx; +// Returns the total number of pages to be displayed. +- (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView; -@end +// Draws the content of the given page in the given Core Graphics context. Your +// implementation should draw within the bounding box returned by +// CGContextGetClipBoundingBox(context). +- (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)context; +@end @protocol LeavesViewDelegate - @optional -// called when the user touches up on the left or right side of the page, or finishes dragging the page -- (void) leavesView:(LeavesView *)leavesView willTurnToPageAtIndex:(NSUInteger)pageIndex; +// Called when the user triggers a page turn by touching up in the left or right +// margin, or by completing a page-turn gesture. +- (void)leavesView:(LeavesView *)leavesView willTurnToPageAtIndex:(NSUInteger)pageIndex; -// called when the page-turn animation (following a touch-up or drag) completes -- (void) leavesView:(LeavesView *)leavesView didTurnToPageAtIndex:(NSUInteger)pageIndex; +// Called when the animation accompanying a page turn completes. +- (void)leavesView:(LeavesView *)leavesView didTurnToPageAtIndex:(NSUInteger)pageIndex; @end diff --git a/Leaves/LeavesView.m b/Leaves/LeavesView.m index 6a6ee11..5a4aba7 100644 --- a/Leaves/LeavesView.m +++ b/Leaves/LeavesView.m @@ -7,10 +7,21 @@ // #import "LeavesView.h" +#import "LeavesCache.h" @interface LeavesView () -@property (assign) CGFloat leafEdge; +@property (readonly) CALayer *topPage, *topPageOverlay, *topPageReverse, +*topPageReverseImage, *topPageReverseOverlay, *bottomPage; +@property (readonly) CAGradientLayer *topPageShadow, *topPageReverseShading, +*bottomPageShadow; +@property (nonatomic, assign) NSUInteger numberOfPages; +@property (nonatomic, assign) CGFloat leafEdge; +@property (nonatomic, assign) CGSize pageSize; +@property (nonatomic, assign) CGPoint touchBeganPoint; +@property (nonatomic, assign) CGRect nextPageRect, prevPageRect; +@property (nonatomic, assign) BOOL touchIsActive, interactionLocked; +@property (readonly) LeavesCache *pageCache; @end @@ -18,214 +29,207 @@ @interface LeavesView () @implementation LeavesView -@synthesize delegate; -@synthesize leafEdge, currentPageIndex, backgroundRendering, preferredTargetWidth; - -- (void) setUpLayers { +- (void)initCommon { self.clipsToBounds = YES; - topPage = [[CALayer alloc] init]; - topPage.masksToBounds = YES; - topPage.contentsGravity = kCAGravityLeft; - topPage.backgroundColor = [[UIColor whiteColor] CGColor]; + _topPage = [[CALayer alloc] init]; + _topPage.masksToBounds = YES; + _topPage.contentsGravity = kCAGravityLeft; + _topPage.backgroundColor = [[UIColor whiteColor] CGColor]; - topPageOverlay = [[CALayer alloc] init]; - topPageOverlay.backgroundColor = [[[UIColor blackColor] colorWithAlphaComponent:0.2] CGColor]; + _topPageOverlay = [[CALayer alloc] init]; + _topPageOverlay.backgroundColor = [[[UIColor blackColor] colorWithAlphaComponent:0.2] CGColor]; - topPageShadow = [[CAGradientLayer alloc] init]; - topPageShadow.colors = [NSArray arrayWithObjects: + _topPageShadow = [[CAGradientLayer alloc] init]; + _topPageShadow.colors = [NSArray arrayWithObjects: (id)[[[UIColor blackColor] colorWithAlphaComponent:0.6] CGColor], (id)[[UIColor clearColor] CGColor], nil]; - topPageShadow.startPoint = CGPointMake(1,0.5); - topPageShadow.endPoint = CGPointMake(0,0.5); + _topPageShadow.startPoint = CGPointMake(1,0.5); + _topPageShadow.endPoint = CGPointMake(0,0.5); - topPageReverse = [[CALayer alloc] init]; - topPageReverse.backgroundColor = [[UIColor whiteColor] CGColor]; - topPageReverse.masksToBounds = YES; + _topPageReverse = [[CALayer alloc] init]; + _topPageReverse.backgroundColor = [[UIColor whiteColor] CGColor]; + _topPageReverse.masksToBounds = YES; - topPageReverseImage = [[CALayer alloc] init]; - topPageReverseImage.masksToBounds = YES; - topPageReverseImage.contentsGravity = kCAGravityRight; + _topPageReverseImage = [[CALayer alloc] init]; + _topPageReverseImage.masksToBounds = YES; + _topPageReverseImage.contentsGravity = kCAGravityRight; - topPageReverseOverlay = [[CALayer alloc] init]; - topPageReverseOverlay.backgroundColor = [[[UIColor whiteColor] colorWithAlphaComponent:0.8] CGColor]; + _topPageReverseOverlay = [[CALayer alloc] init]; + _topPageReverseOverlay.backgroundColor = [[[UIColor whiteColor] colorWithAlphaComponent:0.8] CGColor]; - topPageReverseShading = [[CAGradientLayer alloc] init]; - topPageReverseShading.colors = [NSArray arrayWithObjects: + _topPageReverseShading = [[CAGradientLayer alloc] init]; + _topPageReverseShading.colors = [NSArray arrayWithObjects: (id)[[[UIColor blackColor] colorWithAlphaComponent:0.6] CGColor], (id)[[UIColor clearColor] CGColor], nil]; - topPageReverseShading.startPoint = CGPointMake(1,0.5); - topPageReverseShading.endPoint = CGPointMake(0,0.5); + _topPageReverseShading.startPoint = CGPointMake(1,0.5); + _topPageReverseShading.endPoint = CGPointMake(0,0.5); - bottomPage = [[CALayer alloc] init]; - bottomPage.backgroundColor = [[UIColor whiteColor] CGColor]; - bottomPage.masksToBounds = YES; + _bottomPage = [[CALayer alloc] init]; + _bottomPage.backgroundColor = [[UIColor whiteColor] CGColor]; + _bottomPage.masksToBounds = YES; - bottomPageShadow = [[CAGradientLayer alloc] init]; - bottomPageShadow.colors = [NSArray arrayWithObjects: + _bottomPageShadow = [[CAGradientLayer alloc] init]; + _bottomPageShadow.colors = [NSArray arrayWithObjects: (id)[[[UIColor blackColor] colorWithAlphaComponent:0.6] CGColor], (id)[[UIColor clearColor] CGColor], nil]; - bottomPageShadow.startPoint = CGPointMake(0,0.5); - bottomPageShadow.endPoint = CGPointMake(1,0.5); + _bottomPageShadow.startPoint = CGPointMake(0,0.5); + _bottomPageShadow.endPoint = CGPointMake(1,0.5); - [topPage addSublayer:topPageShadow]; - [topPage addSublayer:topPageOverlay]; - [topPageReverse addSublayer:topPageReverseImage]; - [topPageReverse addSublayer:topPageReverseOverlay]; - [topPageReverse addSublayer:topPageReverseShading]; - [bottomPage addSublayer:bottomPageShadow]; - [self.layer addSublayer:bottomPage]; - [self.layer addSublayer:topPage]; - [self.layer addSublayer:topPageReverse]; + [_topPage addSublayer:_topPageShadow]; + [_topPage addSublayer:_topPageOverlay]; + [_topPageReverse addSublayer:_topPageReverseImage]; + [_topPageReverse addSublayer:_topPageReverseOverlay]; + [_topPageReverse addSublayer:_topPageReverseShading]; + [_bottomPage addSublayer:_bottomPageShadow]; + [self.layer addSublayer:_bottomPage]; + [self.layer addSublayer:_topPage]; + [self.layer addSublayer:_topPageReverse]; - self.leafEdge = 1.0; -} - -- (void) initialize { - backgroundRendering = NO; - pageCache = [[LeavesCache alloc] initWithPageSize:self.bounds.size]; + _leafEdge = 1.0; + _backgroundRendering = NO; + _pageCache = [[LeavesCache alloc] initWithPageSize:self.bounds.size]; } - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { - [self setUpLayers]; - [self initialize]; + [self initCommon]; } return self; } -- (void) awakeFromNib { - [super awakeFromNib]; - [self setUpLayers]; - [self initialize]; +- (id)initWithCoder:(NSCoder *)aDecoder { + if (self = [super initWithCoder:aDecoder]) { + [self initCommon]; + } + return self; } - (void)dealloc { - [topPage release]; - [topPageShadow release]; - [topPageOverlay release]; - [topPageReverse release]; - [topPageReverseImage release]; - [topPageReverseOverlay release]; - [topPageReverseShading release]; - [bottomPage release]; - [bottomPageShadow release]; - - [pageCache release]; + [_topPage release]; + [_topPageShadow release]; + [_topPageOverlay release]; + [_topPageReverse release]; + [_topPageReverseImage release]; + [_topPageReverseOverlay release]; + [_topPageReverseShading release]; + [_bottomPage release]; + [_bottomPageShadow release]; + [_pageCache release]; [super dealloc]; } -- (void) reloadData { - [pageCache flush]; - numberOfPages = [pageCache.dataSource numberOfPagesInLeavesView:self]; +- (void)reloadData { + [self.pageCache flush]; + self.numberOfPages = [self.pageCache.dataSource numberOfPagesInLeavesView:self]; self.currentPageIndex = 0; } -- (void) getImages { - if (currentPageIndex < numberOfPages) { - if (currentPageIndex > 0 && backgroundRendering) - [pageCache precacheImageForPageIndex:currentPageIndex-1]; - topPage.contents = (id)[pageCache cachedImageForPageIndex:currentPageIndex]; - topPageReverseImage.contents = (id)[pageCache cachedImageForPageIndex:currentPageIndex]; - if (currentPageIndex < numberOfPages - 1) - bottomPage.contents = (id)[pageCache cachedImageForPageIndex:currentPageIndex + 1]; - [pageCache minimizeToPageIndex:currentPageIndex]; +- (void)getImages { + if (self.currentPageIndex < self.numberOfPages) { + if (self.currentPageIndex > 0 && self.backgroundRendering) + [self.pageCache precacheImageForPageIndex:self.currentPageIndex-1]; + self.topPage.contents = (id)[self.pageCache cachedImageForPageIndex:self.currentPageIndex]; + self.topPageReverseImage.contents = (id)[self.pageCache cachedImageForPageIndex:self.currentPageIndex]; + if (self.currentPageIndex < self.numberOfPages - 1) + self.bottomPage.contents = (id)[self.pageCache cachedImageForPageIndex:self.currentPageIndex + 1]; + [self.pageCache minimizeToPageIndex:self.currentPageIndex]; } else { - topPage.contents = nil; - topPageReverseImage.contents = nil; - bottomPage.contents = nil; + self.topPage.contents = nil; + self.topPageReverseImage.contents = nil; + self.bottomPage.contents = nil; } } -- (void) setLayerFrames { - topPage.frame = CGRectMake(self.layer.bounds.origin.x, +- (void)setLayerFrames { + self.topPage.frame = CGRectMake(self.layer.bounds.origin.x, self.layer.bounds.origin.y, - leafEdge * self.bounds.size.width, + self.leafEdge * self.bounds.size.width, self.layer.bounds.size.height); - topPageReverse.frame = CGRectMake(self.layer.bounds.origin.x + (2*leafEdge-1) * self.bounds.size.width, + self.topPageReverse.frame = CGRectMake(self.layer.bounds.origin.x + (2*self.leafEdge-1) * self.bounds.size.width, self.layer.bounds.origin.y, - (1-leafEdge) * self.bounds.size.width, + (1-self.leafEdge) * self.bounds.size.width, self.layer.bounds.size.height); - bottomPage.frame = self.layer.bounds; - topPageShadow.frame = CGRectMake(topPageReverse.frame.origin.x - 40, + self.bottomPage.frame = self.layer.bounds; + self.topPageShadow.frame = CGRectMake(self.topPageReverse.frame.origin.x - 40, 0, 40, - bottomPage.bounds.size.height); - topPageReverseImage.frame = topPageReverse.bounds; - topPageReverseImage.transform = CATransform3DMakeScale(-1, 1, 1); - topPageReverseOverlay.frame = topPageReverse.bounds; - topPageReverseShading.frame = CGRectMake(topPageReverse.bounds.size.width - 50, + self.bottomPage.bounds.size.height); + self.topPageReverseImage.frame = self.topPageReverse.bounds; + self.topPageReverseImage.transform = CATransform3DMakeScale(-1, 1, 1); + self.topPageReverseOverlay.frame = self.topPageReverse.bounds; + self.topPageReverseShading.frame = CGRectMake(self.topPageReverse.bounds.size.width - 50, 0, 50 + 1, - topPageReverse.bounds.size.height); - bottomPageShadow.frame = CGRectMake(leafEdge * self.bounds.size.width, + self.topPageReverse.bounds.size.height); + self.bottomPageShadow.frame = CGRectMake(self.leafEdge * self.bounds.size.width, 0, 40, - bottomPage.bounds.size.height); - topPageOverlay.frame = topPage.bounds; + self.bottomPage.bounds.size.height); + self.topPageOverlay.frame = self.topPage.bounds; } -- (void) willTurnToPageAtIndex:(NSUInteger)index { - if ([delegate respondsToSelector:@selector(leavesView:willTurnToPageAtIndex:)]) - [delegate leavesView:self willTurnToPageAtIndex:index]; +- (void)willTurnToPageAtIndex:(NSUInteger)index { + if ([self.delegate respondsToSelector:@selector(leavesView:willTurnToPageAtIndex:)]) + [self.delegate leavesView:self willTurnToPageAtIndex:index]; } -- (void) didTurnToPageAtIndex:(NSUInteger)index { - if ([delegate respondsToSelector:@selector(leavesView:didTurnToPageAtIndex:)]) - [delegate leavesView:self didTurnToPageAtIndex:index]; +- (void)didTurnToPageAtIndex:(NSUInteger)index { + if ([self.delegate respondsToSelector:@selector(leavesView:didTurnToPageAtIndex:)]) + [self.delegate leavesView:self didTurnToPageAtIndex:index]; } -- (void) didTurnPageBackward { - interactionLocked = NO; - [self didTurnToPageAtIndex:currentPageIndex]; +- (void)didTurnPageBackward { + self.interactionLocked = NO; + [self didTurnToPageAtIndex:self.currentPageIndex]; } -- (void) didTurnPageForward { - interactionLocked = NO; +- (void)didTurnPageForward { + self.interactionLocked = NO; self.currentPageIndex = self.currentPageIndex + 1; - [self didTurnToPageAtIndex:currentPageIndex]; + [self didTurnToPageAtIndex:self.currentPageIndex]; } -- (BOOL) hasPrevPage { +- (BOOL)hasPrevPage { return self.currentPageIndex > 0; } -- (BOOL) hasNextPage { - return self.currentPageIndex < numberOfPages - 1; +- (BOOL)hasNextPage { + return self.currentPageIndex < self.numberOfPages - 1; } -- (BOOL) touchedNextPage { - return CGRectContainsPoint(nextPageRect, touchBeganPoint); +- (BOOL)touchedNextPage { + return CGRectContainsPoint(self.nextPageRect, self.touchBeganPoint); } -- (BOOL) touchedPrevPage { - return CGRectContainsPoint(prevPageRect, touchBeganPoint); +- (BOOL)touchedPrevPage { + return CGRectContainsPoint(self.prevPageRect, self.touchBeganPoint); } -- (CGFloat) dragThreshold { +- (CGFloat)dragThreshold { // Magic empirical number return 10; } -- (CGFloat) targetWidth { +- (CGFloat)targetWidth { // Magic empirical formula - if (preferredTargetWidth > 0 && preferredTargetWidth < self.bounds.size.width / 2) - return preferredTargetWidth; + if (self.preferredTargetWidth > 0 && self.preferredTargetWidth < self.bounds.size.width / 2) + return self.preferredTargetWidth; else return MAX(28, self.bounds.size.width / 5); } -- (void) updateTargetRects { +- (void)updateTargetRects { CGFloat targetWidth = [self targetWidth]; - nextPageRect = CGRectMake(self.bounds.size.width - targetWidth, + self.nextPageRect = CGRectMake(self.bounds.size.width - targetWidth, 0, targetWidth, self.bounds.size.height); - prevPageRect = CGRectMake(0, + self.prevPageRect = CGRectMake(0, 0, targetWidth, self.bounds.size.height); @@ -233,25 +237,25 @@ - (void) updateTargetRects { #pragma mark accessors -- (id) dataSource { - return pageCache.dataSource; +- (id)dataSource { + return self.pageCache.dataSource; } -- (void) setDataSource:(id)value { - pageCache.dataSource = value; +- (void)setDataSource:(id)value { + self.pageCache.dataSource = value; } -- (void) setLeafEdge:(CGFloat)aLeafEdge { - leafEdge = aLeafEdge; - topPageShadow.opacity = MIN(1.0, 4*(1-leafEdge)); - bottomPageShadow.opacity = MIN(1.0, 4*leafEdge); - topPageOverlay.opacity = MIN(1.0, 4*(1-leafEdge)); +- (void)setLeafEdge:(CGFloat)aLeafEdge { + _leafEdge = aLeafEdge; + self.topPageShadow.opacity = MIN(1.0, 4*(1-self.leafEdge)); + self.bottomPageShadow.opacity = MIN(1.0, 4*self.leafEdge); + self.topPageOverlay.opacity = MIN(1.0, 4*(1-self.leafEdge)); [self setLayerFrames]; } -- (void) setCurrentPageIndex:(NSUInteger)aCurrentPageIndex { - currentPageIndex = aCurrentPageIndex; +- (void)setCurrentPageIndex:(NSUInteger)aCurrentPageIndex { + _currentPageIndex = aCurrentPageIndex; [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue @@ -264,19 +268,19 @@ - (void) setCurrentPageIndex:(NSUInteger)aCurrentPageIndex { [CATransaction commit]; } -- (void) setPreferredTargetWidth:(CGFloat)value { - preferredTargetWidth = value; +- (void)setPreferredTargetWidth:(CGFloat)value { + _preferredTargetWidth = value; [self updateTargetRects]; } -#pragma mark UIResponder methods +#pragma mark UIResponder - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - if (interactionLocked) + if (self.interactionLocked) return; UITouch *touch = [event.allTouches anyObject]; - touchBeganPoint = [touch locationInView:self]; + self.touchBeganPoint = [touch locationInView:self]; if ([self touchedPrevPage] && [self hasPrevPage]) { [CATransaction begin]; @@ -285,17 +289,17 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPageIndex = self.currentPageIndex - 1; self.leafEdge = 0.0; [CATransaction commit]; - touchIsActive = YES; + self.touchIsActive = YES; } else if ([self touchedNextPage] && [self hasNextPage]) - touchIsActive = YES; + self.touchIsActive = YES; else - touchIsActive = NO; + self.touchIsActive = NO; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - if (!touchIsActive) + if (!self.touchIsActive) return; UITouch *touch = [event.allTouches anyObject]; CGPoint touchPoint = [touch locationInView:self]; @@ -309,32 +313,32 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - if (!touchIsActive) + if (!self.touchIsActive) return; - touchIsActive = NO; + self.touchIsActive = NO; UITouch *touch = [event.allTouches anyObject]; CGPoint touchPoint = [touch locationInView:self]; - BOOL dragged = distance(touchPoint, touchBeganPoint) > [self dragThreshold]; + BOOL dragged = distance(touchPoint, self.touchBeganPoint) > [self dragThreshold]; [CATransaction begin]; float duration; if ((dragged && self.leafEdge < 0.5) || (!dragged && [self touchedNextPage])) { - [self willTurnToPageAtIndex:currentPageIndex+1]; + [self willTurnToPageAtIndex:self.currentPageIndex+1]; self.leafEdge = 0; - duration = leafEdge; - interactionLocked = YES; - if (currentPageIndex+2 < numberOfPages && backgroundRendering) - [pageCache precacheImageForPageIndex:currentPageIndex+2]; + duration = self.leafEdge; + self.interactionLocked = YES; + if (self.currentPageIndex+2 < self.numberOfPages && self.backgroundRendering) + [self.pageCache precacheImageForPageIndex:self.currentPageIndex+2]; [self performSelector:@selector(didTurnPageForward) withObject:nil afterDelay:duration + 0.25]; } else { - [self willTurnToPageAtIndex:currentPageIndex]; + [self willTurnToPageAtIndex:self.currentPageIndex]; self.leafEdge = 1.0; - duration = 1 - leafEdge; - interactionLocked = YES; + duration = 1 - self.leafEdge; + self.interactionLocked = YES; [self performSelector:@selector(didTurnPageBackward) withObject:nil afterDelay:duration + 0.25]; @@ -344,19 +348,19 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [CATransaction commit]; } -- (void) layoutSubviews { +- (void)layoutSubviews { [super layoutSubviews]; - - if (!CGSizeEqualToSize(pageSize, self.bounds.size)) { - pageSize = self.bounds.size; + if (!CGSizeEqualToSize(self.pageSize, self.bounds.size)) { + self.pageSize = self.bounds.size; [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; [self setLayerFrames]; [CATransaction commit]; - pageCache.pageSize = self.bounds.size; + + self.pageCache.pageSize = self.bounds.size; [self getImages]; [self updateTargetRects]; } diff --git a/Leaves/LeavesViewController.h b/Leaves/LeavesViewController.h index cb22dc5..5af6cad 100644 --- a/Leaves/LeavesViewController.h +++ b/Leaves/LeavesViewController.h @@ -7,16 +7,18 @@ // #import -#import "LeavesView.h" -@interface LeavesViewController : UIViewController { - LeavesView *leavesView; -} +@class LeavesView; -// added by Lnkd.com?24 - use designated initializer to avoid continuous loop when loaded from NIB -- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle; +// This view controller presents a LeavesView that occupies its entire view, and +// whose data source and delegate are the view controller itself. +// +// Subclasses should provide content by overriding the view controller's +// implementation of the LeavesViewDataSource protocol. +@interface LeavesViewController : UIViewController -- (id)init; +// The LeavesView presented by the view controller. +@property (readonly) LeavesView *leavesView; @end diff --git a/Leaves/LeavesViewController.m b/Leaves/LeavesViewController.m index 29b68c4..45d52ba 100644 --- a/Leaves/LeavesViewController.m +++ b/Leaves/LeavesViewController.m @@ -7,59 +7,47 @@ // #import "LeavesViewController.h" +#import "LeavesView.h" -@implementation LeavesViewController - -- (void) initialize { - leavesView = [[LeavesView alloc] initWithFrame:CGRectZero]; -} +@interface LeavesViewController () -- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle -{ - if (self = [super initWithNibName:nibName bundle:nibBundle]) { - [self initialize]; - } - return self; -} +@end -- (id)init { - return [self initWithNibName:nil bundle:nil]; -} +@implementation LeavesViewController -- (void) awakeFromNib { - [super awakeFromNib]; - [self initialize]; +- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle { + if (self = [super initWithNibName:nibName bundle:nibBundle]) { + _leavesView = [[LeavesView alloc] initWithFrame:CGRectZero]; + _leavesView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _leavesView.dataSource = self; + _leavesView.delegate = self; + } + return self; } - (void)dealloc { - [leavesView release]; + [_leavesView release]; [super dealloc]; } -#pragma mark LeavesViewDataSource methods +#pragma mark LeavesViewDataSource -- (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView { +- (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView { return 0; } -- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { +- (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { } -#pragma mark UIViewController methods - -- (void)loadView { - [super loadView]; - leavesView.frame = self.view.bounds; - leavesView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; - [self.view addSubview:leavesView]; -} +#pragma mark UIViewController -- (void) viewDidLoad { +- (void)viewDidLoad { [super viewDidLoad]; - leavesView.dataSource = self; - leavesView.delegate = self; - [leavesView reloadData]; + + _leavesView.frame = self.view.bounds; + [self.view addSubview:_leavesView]; + [_leavesView reloadData]; } @end diff --git a/Leaves.xcodeproj/project.pbxproj b/LeavesExamples.xcodeproj/project.pbxproj similarity index 57% rename from Leaves.xcodeproj/project.pbxproj rename to LeavesExamples.xcodeproj/project.pbxproj index f0eb30e..c529d76 100755 --- a/Leaves.xcodeproj/project.pbxproj +++ b/LeavesExamples.xcodeproj/project.pbxproj @@ -3,65 +3,67 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ - 1D3623260D0F684500981E51 /* LeavesAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* LeavesAppDelegate.m */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; D337E308119B61A5003E5728 /* LeavesCache.m in Sources */ = {isa = PBXBuildFile; fileRef = D337E307119B61A5003E5728 /* LeavesCache.m */; }; D33D45A2117BDE0100BA7203 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D33D45A1117BDE0100BA7203 /* QuartzCore.framework */; }; - D33D4A0D117C34F000BA7203 /* ImageExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4A0C117C34F000BA7203 /* ImageExampleViewController.m */; }; - D33D4B51117C473500BA7203 /* PDFExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4B50117C473500BA7203 /* PDFExampleViewController.m */; }; - D33D4B85117C4B8F00BA7203 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = D33D4B84117C4B8F00BA7203 /* MainWindow-iPad.xib */; }; D33D4E5B117D818100BA7203 /* LeavesView.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4E58117D818100BA7203 /* LeavesView.m */; }; D33D4E5C117D818100BA7203 /* LeavesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4E5A117D818100BA7203 /* LeavesViewController.m */; }; - D33D4ECC117D8D4500BA7203 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4EC3117D8D4500BA7203 /* Utilities.m */; }; - D33D4ECD117D8D4500BA7203 /* kitten.jpg in Resources */ = {isa = PBXBuildFile; fileRef = D33D4EC5117D8D4500BA7203 /* kitten.jpg */; }; - D33D4ECE117D8D4500BA7203 /* kitten2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = D33D4EC6117D8D4500BA7203 /* kitten2.jpg */; }; - D33D4ECF117D8D4500BA7203 /* kitten3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = D33D4EC7117D8D4500BA7203 /* kitten3.jpg */; }; - D33D4ED1117D8D4500BA7203 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = D33D4EC9117D8D4500BA7203 /* MainWindow.xib */; }; - D33D4ED2117D8D4500BA7203 /* paper.pdf in Resources */ = {isa = PBXBuildFile; fileRef = D33D4ECA117D8D4500BA7203 /* paper.pdf */; }; - D33D4F01117D8EAE00BA7203 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4F00117D8EAE00BA7203 /* main.m */; }; - D33D4F41117E244C00BA7203 /* ExamplesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4F40117E244C00BA7203 /* ExamplesViewController.m */; }; - D33D5176117E780300BA7203 /* ProceduralExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D5175117E780300BA7203 /* ProceduralExampleViewController.m */; }; + EA97678A17EB8E3C001A0F1C /* ExamplesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97677317EB8E3C001A0F1C /* ExamplesViewController.m */; }; + EA97678B17EB8E3C001A0F1C /* ImageExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97677517EB8E3C001A0F1C /* ImageExampleViewController.m */; }; + EA97678C17EB8E3C001A0F1C /* LeavesAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97677717EB8E3C001A0F1C /* LeavesAppDelegate.m */; }; + EA97678D17EB8E3C001A0F1C /* PDFExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97677917EB8E3C001A0F1C /* PDFExampleViewController.m */; }; + EA97678E17EB8E3C001A0F1C /* ProceduralExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97677B17EB8E3C001A0F1C /* ProceduralExampleViewController.m */; }; + EA97679117EB8E3C001A0F1C /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EA97678217EB8E3C001A0F1C /* Default-568h@2x.png */; }; + EA97679217EB8E3C001A0F1C /* kitten.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EA97678317EB8E3C001A0F1C /* kitten.jpg */; }; + EA97679317EB8E3C001A0F1C /* kitten2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EA97678417EB8E3C001A0F1C /* kitten2.jpg */; }; + EA97679417EB8E3C001A0F1C /* kitten3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = EA97678517EB8E3C001A0F1C /* kitten3.jpg */; }; + EA97679617EB8E3C001A0F1C /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = EA97678717EB8E3C001A0F1C /* MainWindow-iPad.xib */; }; + EA97679717EB8E3C001A0F1C /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = EA97678817EB8E3C001A0F1C /* MainWindow.xib */; }; + EA97679817EB8E3C001A0F1C /* paper.pdf in Resources */ = {isa = PBXBuildFile; fileRef = EA97678917EB8E3C001A0F1C /* paper.pdf */; }; + EA97679B17EB8FAB001A0F1C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97679A17EB8FAB001A0F1C /* main.m */; }; + EA97679E17EB8FB2001A0F1C /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EA97679D17EB8FB2001A0F1C /* Utilities.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1D3623240D0F684500981E51 /* LeavesAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeavesAppDelegate.h; sourceTree = ""; }; - 1D3623250D0F684500981E51 /* LeavesAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeavesAppDelegate.m; sourceTree = ""; }; - 1D6058910D05DD3D006BFB54 /* Leaves.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Leaves.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D6058910D05DD3D006BFB54 /* LeavesExamples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LeavesExamples.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; D337E306119B61A5003E5728 /* LeavesCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeavesCache.h; sourceTree = ""; }; D337E307119B61A5003E5728 /* LeavesCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeavesCache.m; sourceTree = ""; }; D33D45A1117BDE0100BA7203 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; - D33D4A0B117C34F000BA7203 /* ImageExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageExampleViewController.h; sourceTree = ""; }; - D33D4A0C117C34F000BA7203 /* ImageExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageExampleViewController.m; sourceTree = ""; }; - D33D4B4F117C473500BA7203 /* PDFExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFExampleViewController.h; sourceTree = ""; }; - D33D4B50117C473500BA7203 /* PDFExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDFExampleViewController.m; sourceTree = ""; }; - D33D4B84117C4B8F00BA7203 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MainWindow-iPad.xib"; path = "Resources-iPad/MainWindow-iPad.xib"; sourceTree = ""; }; D33D4E57117D818100BA7203 /* LeavesView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeavesView.h; sourceTree = ""; }; D33D4E58117D818100BA7203 /* LeavesView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeavesView.m; sourceTree = ""; }; D33D4E59117D818100BA7203 /* LeavesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeavesViewController.h; sourceTree = ""; }; D33D4E5A117D818100BA7203 /* LeavesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeavesViewController.m; sourceTree = ""; }; - D33D4EC2117D8D4500BA7203 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = ""; }; - D33D4EC3117D8D4500BA7203 /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = ""; }; - D33D4EC5117D8D4500BA7203 /* kitten.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kitten.jpg; sourceTree = ""; }; - D33D4EC6117D8D4500BA7203 /* kitten2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kitten2.jpg; sourceTree = ""; }; - D33D4EC7117D8D4500BA7203 /* kitten3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kitten3.jpg; sourceTree = ""; }; - D33D4EC9117D8D4500BA7203 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; - D33D4ECA117D8D4500BA7203 /* paper.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = paper.pdf; sourceTree = ""; }; - D33D4EDA117D8DCD00BA7203 /* Leaves-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Leaves-Info.plist"; sourceTree = SOURCE_ROOT; }; - D33D4EFB117D8E7800BA7203 /* Leaves_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Leaves_Prefix.pch; sourceTree = SOURCE_ROOT; }; - D33D4F00117D8EAE00BA7203 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; - D33D4F3F117E244C00BA7203 /* ExamplesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExamplesViewController.h; sourceTree = ""; }; - D33D4F40117E244C00BA7203 /* ExamplesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExamplesViewController.m; sourceTree = ""; }; - D33D5174117E780300BA7203 /* ProceduralExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProceduralExampleViewController.h; sourceTree = ""; }; - D33D5175117E780300BA7203 /* ProceduralExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProceduralExampleViewController.m; sourceTree = ""; }; + EA97677217EB8E3C001A0F1C /* ExamplesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExamplesViewController.h; sourceTree = ""; }; + EA97677317EB8E3C001A0F1C /* ExamplesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExamplesViewController.m; sourceTree = ""; }; + EA97677417EB8E3C001A0F1C /* ImageExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageExampleViewController.h; sourceTree = ""; }; + EA97677517EB8E3C001A0F1C /* ImageExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageExampleViewController.m; sourceTree = ""; }; + EA97677617EB8E3C001A0F1C /* LeavesAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeavesAppDelegate.h; sourceTree = ""; }; + EA97677717EB8E3C001A0F1C /* LeavesAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeavesAppDelegate.m; sourceTree = ""; }; + EA97677817EB8E3C001A0F1C /* PDFExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFExampleViewController.h; sourceTree = ""; }; + EA97677917EB8E3C001A0F1C /* PDFExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDFExampleViewController.m; sourceTree = ""; }; + EA97677A17EB8E3C001A0F1C /* ProceduralExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProceduralExampleViewController.h; sourceTree = ""; }; + EA97677B17EB8E3C001A0F1C /* ProceduralExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProceduralExampleViewController.m; sourceTree = ""; }; + EA97678217EB8E3C001A0F1C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + EA97678317EB8E3C001A0F1C /* kitten.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kitten.jpg; sourceTree = ""; }; + EA97678417EB8E3C001A0F1C /* kitten2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kitten2.jpg; sourceTree = ""; }; + EA97678517EB8E3C001A0F1C /* kitten3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kitten3.jpg; sourceTree = ""; }; + EA97678617EB8E3C001A0F1C /* LeavesExamples-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "LeavesExamples-Info.plist"; sourceTree = ""; }; + EA97678717EB8E3C001A0F1C /* MainWindow-iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "MainWindow-iPad.xib"; sourceTree = ""; }; + EA97678817EB8E3C001A0F1C /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + EA97678917EB8E3C001A0F1C /* paper.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = paper.pdf; sourceTree = ""; }; + EA97679917EB8FAB001A0F1C /* LeavesExamples_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LeavesExamples_Prefix.pch; path = LeavesExamples/LeavesExamples_Prefix.pch; sourceTree = SOURCE_ROOT; }; + EA97679A17EB8FAB001A0F1C /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = LeavesExamples/main.m; sourceTree = SOURCE_ROOT; }; + EA97679C17EB8FB2001A0F1C /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utilities.h; path = LeavesExamples/Other/Utilities.h; sourceTree = SOURCE_ROOT; }; + EA97679D17EB8FB2001A0F1C /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Utilities.m; path = LeavesExamples/Other/Utilities.m; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -79,27 +81,10 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 080E96DDFE201D6D7F000001 /* Classes */ = { - isa = PBXGroup; - children = ( - 1D3623240D0F684500981E51 /* LeavesAppDelegate.h */, - 1D3623250D0F684500981E51 /* LeavesAppDelegate.m */, - D33D4A0B117C34F000BA7203 /* ImageExampleViewController.h */, - D33D4A0C117C34F000BA7203 /* ImageExampleViewController.m */, - D33D4B4F117C473500BA7203 /* PDFExampleViewController.h */, - D33D4B50117C473500BA7203 /* PDFExampleViewController.m */, - D33D4F3F117E244C00BA7203 /* ExamplesViewController.h */, - D33D4F40117E244C00BA7203 /* ExamplesViewController.m */, - D33D5174117E780300BA7203 /* ProceduralExampleViewController.h */, - D33D5175117E780300BA7203 /* ProceduralExampleViewController.m */, - ); - path = Classes; - sourceTree = ""; - }; 19C28FACFE9D520D11CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 1D6058910D05DD3D006BFB54 /* Leaves.app */, + 1D6058910D05DD3D006BFB54 /* LeavesExamples.app */, ); name = Products; sourceTree = ""; @@ -108,10 +93,9 @@ isa = PBXGroup; children = ( D33D4E56117D818100BA7203 /* Leaves */, - 080E96DDFE201D6D7F000001 /* Classes */, - D33D4EBF117D8D4500BA7203 /* Other Sources */, - D33D4EC4117D8D4500BA7203 /* Resources */, - D33D4B83117C4B8B00BA7203 /* Resources-iPad */, + EA97677117EB8E3C001A0F1C /* Classes */, + EA97677C17EB8E3C001A0F1C /* Other Sources */, + EA97678117EB8E3C001A0F1C /* Resources */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 19C28FACFE9D520D11CA2CBB /* Products */, ); @@ -129,14 +113,6 @@ name = Frameworks; sourceTree = ""; }; - D33D4B83117C4B8B00BA7203 /* Resources-iPad */ = { - isa = PBXGroup; - children = ( - D33D4B84117C4B8F00BA7203 /* MainWindow-iPad.xib */, - ); - name = "Resources-iPad"; - sourceTree = ""; - }; D33D4E56117D818100BA7203 /* Leaves */ = { isa = PBXGroup; children = ( @@ -150,36 +126,58 @@ path = Leaves; sourceTree = ""; }; - D33D4EBF117D8D4500BA7203 /* Other Sources */ = { + EA97677117EB8E3C001A0F1C /* Classes */ = { + isa = PBXGroup; + children = ( + EA97677217EB8E3C001A0F1C /* ExamplesViewController.h */, + EA97677317EB8E3C001A0F1C /* ExamplesViewController.m */, + EA97677417EB8E3C001A0F1C /* ImageExampleViewController.h */, + EA97677517EB8E3C001A0F1C /* ImageExampleViewController.m */, + EA97677617EB8E3C001A0F1C /* LeavesAppDelegate.h */, + EA97677717EB8E3C001A0F1C /* LeavesAppDelegate.m */, + EA97677817EB8E3C001A0F1C /* PDFExampleViewController.h */, + EA97677917EB8E3C001A0F1C /* PDFExampleViewController.m */, + EA97677A17EB8E3C001A0F1C /* ProceduralExampleViewController.h */, + EA97677B17EB8E3C001A0F1C /* ProceduralExampleViewController.m */, + ); + name = Classes; + path = LeavesExamples/Classes; + sourceTree = ""; + }; + EA97677C17EB8E3C001A0F1C /* Other Sources */ = { isa = PBXGroup; children = ( - D33D4F00117D8EAE00BA7203 /* main.m */, - D33D4EFB117D8E7800BA7203 /* Leaves_Prefix.pch */, - D33D4EC2117D8D4500BA7203 /* Utilities.h */, - D33D4EC3117D8D4500BA7203 /* Utilities.m */, + EA97679917EB8FAB001A0F1C /* LeavesExamples_Prefix.pch */, + EA97679A17EB8FAB001A0F1C /* main.m */, + EA97679C17EB8FB2001A0F1C /* Utilities.h */, + EA97679D17EB8FB2001A0F1C /* Utilities.m */, ); - path = "Other Sources"; + name = "Other Sources"; + path = "LeavesExamples/Other Sources"; sourceTree = ""; }; - D33D4EC4117D8D4500BA7203 /* Resources */ = { + EA97678117EB8E3C001A0F1C /* Resources */ = { isa = PBXGroup; children = ( - D33D4EDA117D8DCD00BA7203 /* Leaves-Info.plist */, - D33D4EC9117D8D4500BA7203 /* MainWindow.xib */, - D33D4EC5117D8D4500BA7203 /* kitten.jpg */, - D33D4EC6117D8D4500BA7203 /* kitten2.jpg */, - D33D4EC7117D8D4500BA7203 /* kitten3.jpg */, - D33D4ECA117D8D4500BA7203 /* paper.pdf */, + EA97678217EB8E3C001A0F1C /* Default-568h@2x.png */, + EA97678317EB8E3C001A0F1C /* kitten.jpg */, + EA97678417EB8E3C001A0F1C /* kitten2.jpg */, + EA97678517EB8E3C001A0F1C /* kitten3.jpg */, + EA97678617EB8E3C001A0F1C /* LeavesExamples-Info.plist */, + EA97678717EB8E3C001A0F1C /* MainWindow-iPad.xib */, + EA97678817EB8E3C001A0F1C /* MainWindow.xib */, + EA97678917EB8E3C001A0F1C /* paper.pdf */, ); - path = Resources; + name = Resources; + path = LeavesExamples/Resources; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 1D6058900D05DD3D006BFB54 /* Leaves */ = { + 1D6058900D05DD3D006BFB54 /* LeavesExamples */ = { isa = PBXNativeTarget; - buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Leaves" */; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "LeavesExamples" */; buildPhases = ( 1D60588D0D05DD3D006BFB54 /* Resources */, 1D60588E0D05DD3D006BFB54 /* Sources */, @@ -189,9 +187,9 @@ ); dependencies = ( ); - name = Leaves; + name = LeavesExamples; productName = Leaves; - productReference = 1D6058910D05DD3D006BFB54 /* Leaves.app */; + productReference = 1D6058910D05DD3D006BFB54 /* LeavesExamples.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -200,16 +198,21 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { + LastUpgradeCheck = 0500; ORGANIZATIONNAME = "Tom Brow"; }; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Leaves" */; - compatibilityVersion = "Xcode 3.1"; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "LeavesExamples" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + en, + ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; projectRoot = ""; targets = ( - 1D6058900D05DD3D006BFB54 /* Leaves */, + 1D6058900D05DD3D006BFB54 /* LeavesExamples */, ); }; /* End PBXProject section */ @@ -219,12 +222,13 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - D33D4B85117C4B8F00BA7203 /* MainWindow-iPad.xib in Resources */, - D33D4ECD117D8D4500BA7203 /* kitten.jpg in Resources */, - D33D4ECE117D8D4500BA7203 /* kitten2.jpg in Resources */, - D33D4ECF117D8D4500BA7203 /* kitten3.jpg in Resources */, - D33D4ED1117D8D4500BA7203 /* MainWindow.xib in Resources */, - D33D4ED2117D8D4500BA7203 /* paper.pdf in Resources */, + EA97679717EB8E3C001A0F1C /* MainWindow.xib in Resources */, + EA97679817EB8E3C001A0F1C /* paper.pdf in Resources */, + EA97679417EB8E3C001A0F1C /* kitten3.jpg in Resources */, + EA97679217EB8E3C001A0F1C /* kitten.jpg in Resources */, + EA97679117EB8E3C001A0F1C /* Default-568h@2x.png in Resources */, + EA97679617EB8E3C001A0F1C /* MainWindow-iPad.xib in Resources */, + EA97679317EB8E3C001A0F1C /* kitten2.jpg in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -235,15 +239,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 1D3623260D0F684500981E51 /* LeavesAppDelegate.m in Sources */, - D33D4A0D117C34F000BA7203 /* ImageExampleViewController.m in Sources */, - D33D4B51117C473500BA7203 /* PDFExampleViewController.m in Sources */, + EA97678E17EB8E3C001A0F1C /* ProceduralExampleViewController.m in Sources */, D33D4E5B117D818100BA7203 /* LeavesView.m in Sources */, + EA97678A17EB8E3C001A0F1C /* ExamplesViewController.m in Sources */, + EA97678D17EB8E3C001A0F1C /* PDFExampleViewController.m in Sources */, + EA97679E17EB8FB2001A0F1C /* Utilities.m in Sources */, + EA97678B17EB8E3C001A0F1C /* ImageExampleViewController.m in Sources */, D33D4E5C117D818100BA7203 /* LeavesViewController.m in Sources */, - D33D4ECC117D8D4500BA7203 /* Utilities.m in Sources */, - D33D4F01117D8EAE00BA7203 /* main.m in Sources */, - D33D4F41117E244C00BA7203 /* ExamplesViewController.m in Sources */, - D33D5176117E780300BA7203 /* ProceduralExampleViewController.m in Sources */, + EA97678C17EB8E3C001A0F1C /* LeavesAppDelegate.m in Sources */, + EA97679B17EB8FAB001A0F1C /* main.m in Sources */, D337E308119B61A5003E5728 /* LeavesCache.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -255,15 +259,13 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Leaves_Prefix.pch; - INFOPLIST_FILE = "Leaves-Info.plist"; - PRODUCT_NAME = Leaves; - SDKROOT = iphoneos3.2; + INFOPLIST_FILE = "$(SRCROOT)/LeavesExamples/Resources/LeavesExamples-Info.plist"; + PRODUCT_NAME = LeavesExamples; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -272,13 +274,11 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; COPY_PHASE_STRIP = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Leaves_Prefix.pch; - INFOPLIST_FILE = "Leaves-Info.plist"; - PRODUCT_NAME = Leaves; - SDKROOT = iphoneos3.2; + INFOPLIST_FILE = "$(SRCROOT)/LeavesExamples/Resources/LeavesExamples-Info.plist"; + PRODUCT_NAME = LeavesExamples; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -287,34 +287,37 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREFIX_HEADER = "$(SRCROOT)/LeavesExamples/LeavesExamples_Prefix.pch"; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.2; + ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; - SDKROOT = iphoneos3.0; + SDKROOT = iphoneos; }; name = Debug; }; C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREFIX_HEADER = "$(SRCROOT)/LeavesExamples/LeavesExamples_Prefix.pch"; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.2; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PREBINDING = NO; - SDKROOT = iphoneos3.0; + SDKROOT = iphoneos; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Leaves" */ = { + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "LeavesExamples" */ = { isa = XCConfigurationList; buildConfigurations = ( 1D6058940D05DD3E006BFB54 /* Debug */, @@ -323,7 +326,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Leaves" */ = { + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "LeavesExamples" */ = { isa = XCConfigurationList; buildConfigurations = ( C01FCF4F08A954540054247B /* Debug */, diff --git a/Classes/ExamplesViewController.h b/LeavesExamples/Classes/ExamplesViewController.h similarity index 66% rename from Classes/ExamplesViewController.h rename to LeavesExamples/Classes/ExamplesViewController.h index 8e9d1f3..ce0cf88 100644 --- a/Classes/ExamplesViewController.h +++ b/LeavesExamples/Classes/ExamplesViewController.h @@ -1,6 +1,6 @@ // // ExamplesViewController.h -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/20/10. // Copyright 2010 Tom Brow. All rights reserved. @@ -8,8 +8,6 @@ #import - -@interface ExamplesViewController : UITableViewController { -} +@interface ExamplesViewController : UITableViewController @end diff --git a/Classes/ExamplesViewController.m b/LeavesExamples/Classes/ExamplesViewController.m similarity index 67% rename from Classes/ExamplesViewController.m rename to LeavesExamples/Classes/ExamplesViewController.m index 886702e..8a42bc6 100644 --- a/Classes/ExamplesViewController.m +++ b/LeavesExamples/Classes/ExamplesViewController.m @@ -1,6 +1,6 @@ // // ExamplesViewController.m -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/20/10. // Copyright 2010 Tom Brow. All rights reserved. @@ -11,21 +11,17 @@ #import "ImageExampleViewController.h" #import "ProceduralExampleViewController.h" -enum {PDF, IMAGE, PROCEDURAL, NUM_EXAMPLES}; +enum {ExamplePDF, ExampleImage, ExampleProcedural, NumExamples}; @implementation ExamplesViewController - (id)init { - if ((self = [super initWithStyle:UITableViewStyleGrouped])) { + if (self = [super initWithStyle:UITableViewStyleGrouped]) { } return self; } -- (void)dealloc { - [super dealloc]; -} - -#pragma mark UITableViewDataSource methods +#pragma mark UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; @@ -33,11 +29,9 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return NUM_EXAMPLES; + return NumExamples; } - -// Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; @@ -48,32 +42,34 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } switch (indexPath.row) { - case PDF: cell.textLabel.text = @"PDF example"; break; - case IMAGE: cell.textLabel.text = @"Image example"; break; - case PROCEDURAL: cell.textLabel.text = @"Procedural example"; break; + case ExamplePDF: cell.textLabel.text = @"PDF example"; break; + case ExampleImage: cell.textLabel.text = @"Image example"; break; + case ExampleProcedural: cell.textLabel.text = @"Procedural example"; break; default: cell.textLabel.text = @""; } return cell; } -#pragma mark UITableViewDelegate methods +#pragma mark UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIViewController *viewController; switch (indexPath.row) { - case PDF: + case ExamplePDF: viewController = [[[PDFExampleViewController alloc] init] autorelease]; break; - case IMAGE: + case ExampleImage: viewController = [[[ImageExampleViewController alloc] init] autorelease]; break; - case PROCEDURAL: + case ExampleProcedural: viewController = [[[ProceduralExampleViewController alloc] init] autorelease]; break; default: - viewController = [[[UIViewController alloc] init] autorelease]; - } - [self.navigationController pushViewController:viewController animated:YES]; + viewController = nil; + } + + if (viewController) + [self.navigationController pushViewController:viewController animated:YES]; } diff --git a/Classes/ImageExampleViewController.h b/LeavesExamples/Classes/ImageExampleViewController.h similarity index 63% rename from Classes/ImageExampleViewController.h rename to LeavesExamples/Classes/ImageExampleViewController.h index 735e65e..2a651f5 100644 --- a/Classes/ImageExampleViewController.h +++ b/LeavesExamples/Classes/ImageExampleViewController.h @@ -1,6 +1,6 @@ // // ExampleViewController.h -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/18/10. // Copyright 2010 Tom Brow. All rights reserved. @@ -8,8 +8,6 @@ #import "LeavesViewController.h" -@interface ImageExampleViewController : LeavesViewController { - NSArray *images; -} +@interface ImageExampleViewController : LeavesViewController @end diff --git a/Classes/ImageExampleViewController.m b/LeavesExamples/Classes/ImageExampleViewController.m similarity index 51% rename from Classes/ImageExampleViewController.m rename to LeavesExamples/Classes/ImageExampleViewController.m index 5e407f0..afb12df 100644 --- a/Classes/ImageExampleViewController.m +++ b/LeavesExamples/Classes/ImageExampleViewController.m @@ -9,32 +9,38 @@ #import "ImageExampleViewController.h" #import "Utilities.h" +@interface ImageExampleViewController () + +@property (readonly) NSArray *images; + +@end + @implementation ImageExampleViewController - (id)init { if (self = [super init]) { - images = [[NSArray alloc] initWithObjects: - [UIImage imageNamed:@"kitten.jpg"], - [UIImage imageNamed:@"kitten2.jpg"], - [UIImage imageNamed:@"kitten3.jpg"], - nil]; + _images = [[NSArray alloc] initWithObjects: + [UIImage imageNamed:@"kitten.jpg"], + [UIImage imageNamed:@"kitten2.jpg"], + [UIImage imageNamed:@"kitten3.jpg"], + nil]; } return self; } - (void)dealloc { - [images release]; + [_images release]; [super dealloc]; } -#pragma mark LeavesViewDataSource methods +#pragma mark LeavesViewDataSource -- (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView { - return images.count; +- (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView { + return _images.count; } -- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { - UIImage *image = [images objectAtIndex:index]; +- (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { + UIImage *image = [_images objectAtIndex:index]; CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height); CGAffineTransform transform = aspectFit(imageRect, CGContextGetClipBoundingBox(ctx)); diff --git a/LeavesExamples/Classes/LeavesAppDelegate.h b/LeavesExamples/Classes/LeavesAppDelegate.h new file mode 100644 index 0000000..798a65d --- /dev/null +++ b/LeavesExamples/Classes/LeavesAppDelegate.h @@ -0,0 +1,14 @@ +// +// LeavesAppDelegate.h +// LeavesExamples +// +// Created by Tom Brow on 4/18/10. +// Copyright Tom Brow 2010. All rights reserved. +// + +#import + +@interface LeavesAppDelegate : NSObject + +@end + diff --git a/Classes/LeavesAppDelegate.m b/LeavesExamples/Classes/LeavesAppDelegate.m similarity index 65% rename from Classes/LeavesAppDelegate.m rename to LeavesExamples/Classes/LeavesAppDelegate.m index 2f55456..36ef3db 100644 --- a/Classes/LeavesAppDelegate.m +++ b/LeavesExamples/Classes/LeavesAppDelegate.m @@ -1,6 +1,6 @@ // // LeavesAppDelegate.m -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/18/10. // Copyright Tom Brow 2010. All rights reserved. @@ -11,22 +11,18 @@ @implementation LeavesAppDelegate -@synthesize window; +@synthesize window=_window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIViewController *rootViewController = [[[ExamplesViewController alloc] init] autorelease]; - viewController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; - - [window addSubview:viewController.view]; - [window makeKeyAndVisible]; + self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; + [self.window makeKeyAndVisible]; return YES; } - - (void)dealloc { - [viewController release]; - [window release]; + [_window release]; [super dealloc]; } diff --git a/Classes/PDFExampleViewController.h b/LeavesExamples/Classes/PDFExampleViewController.h similarity index 63% rename from Classes/PDFExampleViewController.h rename to LeavesExamples/Classes/PDFExampleViewController.h index 40a1119..2021cb6 100644 --- a/Classes/PDFExampleViewController.h +++ b/LeavesExamples/Classes/PDFExampleViewController.h @@ -1,6 +1,6 @@ // // PDFExampleViewController.h -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/19/10. // Copyright 2010 Tom Brow. All rights reserved. @@ -8,8 +8,6 @@ #import "LeavesViewController.h" -@interface PDFExampleViewController : LeavesViewController { - CGPDFDocumentRef pdf; -} +@interface PDFExampleViewController : LeavesViewController @end diff --git a/LeavesExamples/Classes/PDFExampleViewController.m b/LeavesExamples/Classes/PDFExampleViewController.m new file mode 100644 index 0000000..0f45dfb --- /dev/null +++ b/LeavesExamples/Classes/PDFExampleViewController.m @@ -0,0 +1,65 @@ +// +// PDFExampleViewController.m +// LeavesExamples +// +// Created by Tom Brow on 4/19/10. +// Copyright 2010 Tom Brow. All rights reserved. +// + +#import "PDFExampleViewController.h" +#import "Utilities.h" +#import "LeavesView.h" + +@interface PDFExampleViewController () + +@property (readonly) CGPDFDocumentRef pdf; + +@end + +@implementation PDFExampleViewController + +- (id)init { + if (self = [super init]) { + CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("paper.pdf"), NULL, NULL); + _pdf = CGPDFDocumentCreateWithURL(pdfURL); + CFRelease(pdfURL); + + self.leavesView.backgroundRendering = YES; + [self displayPageNumber:1]; + } + return self; +} + +- (void)dealloc { + CGPDFDocumentRelease(_pdf); + [super dealloc]; +} + +- (void)displayPageNumber:(NSUInteger)pageNumber { + self.navigationItem.title = [NSString stringWithFormat: + @"Page %u of %lu", + pageNumber, + CGPDFDocumentGetNumberOfPages(_pdf)]; +} + +#pragma mark LeavesViewDelegate + +- (void)leavesView:(LeavesView *)leavesView willTurnToPageAtIndex:(NSUInteger)pageIndex { + [self displayPageNumber:pageIndex + 1]; +} + +#pragma mark LeavesViewDataSource + +- (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView { + return CGPDFDocumentGetNumberOfPages(_pdf); +} + +- (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { + CGPDFPageRef page = CGPDFDocumentGetPage(_pdf, index + 1); + CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFMediaBox), + CGContextGetClipBoundingBox(ctx)); + CGContextConcatCTM(ctx, transform); + CGContextDrawPDFPage(ctx, page); +} + +@end diff --git a/Classes/ProceduralExampleViewController.h b/LeavesExamples/Classes/ProceduralExampleViewController.h similarity index 91% rename from Classes/ProceduralExampleViewController.h rename to LeavesExamples/Classes/ProceduralExampleViewController.h index 1f93d01..c3af473 100644 --- a/Classes/ProceduralExampleViewController.h +++ b/LeavesExamples/Classes/ProceduralExampleViewController.h @@ -1,6 +1,6 @@ // // MinimalExampleViewController.h -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/20/10. // Copyright 2010 Tom Brow. All rights reserved. @@ -8,9 +8,6 @@ #import "LeavesViewController.h" - -@interface ProceduralExampleViewController : LeavesViewController { - -} +@interface ProceduralExampleViewController : LeavesViewController @end diff --git a/Classes/ProceduralExampleViewController.m b/LeavesExamples/Classes/ProceduralExampleViewController.m similarity index 72% rename from Classes/ProceduralExampleViewController.m rename to LeavesExamples/Classes/ProceduralExampleViewController.m index 193e02b..704db64 100644 --- a/Classes/ProceduralExampleViewController.m +++ b/LeavesExamples/Classes/ProceduralExampleViewController.m @@ -1,6 +1,6 @@ // // MinimalExampleViewController.m -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/20/10. // Copyright 2010 Tom Brow. All rights reserved. @@ -11,13 +11,13 @@ @implementation ProceduralExampleViewController -#pragma mark LeavesViewDataSource methods +#pragma mark LeavesViewDataSource -- (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView { +- (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView { return 10; } -- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { +- (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { CGRect bounds = CGContextGetClipBoundingBox(ctx); CGContextSetFillColorWithColor(ctx, [[UIColor colorWithHue:index/10.0 saturation:0.8 diff --git a/LeavesExamples/LeavesExamples_Prefix.pch b/LeavesExamples/LeavesExamples_Prefix.pch new file mode 100644 index 0000000..4da093f --- /dev/null +++ b/LeavesExamples/LeavesExamples_Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'LeavesExamples' target in the 'LeavesExamples' project +// + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Other Sources/Utilities.h b/LeavesExamples/Other/Utilities.h similarity index 91% rename from Other Sources/Utilities.h rename to LeavesExamples/Other/Utilities.h index 1b42b13..1433f28 100644 --- a/Other Sources/Utilities.h +++ b/LeavesExamples/Other/Utilities.h @@ -1,6 +1,6 @@ // // Utilities.h -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/19/10. // Copyright 2010 Tom Brow. All rights reserved. diff --git a/Other Sources/Utilities.m b/LeavesExamples/Other/Utilities.m similarity index 97% rename from Other Sources/Utilities.m rename to LeavesExamples/Other/Utilities.m index c6e60b7..5ef5a94 100644 --- a/Other Sources/Utilities.m +++ b/LeavesExamples/Other/Utilities.m @@ -1,6 +1,6 @@ // // Utilities.m -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/19/10. // Copyright 2010 Tom Brow. All rights reserved. diff --git a/LeavesExamples/Resources/Default-568h@2x.png b/LeavesExamples/Resources/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/LeavesExamples/Resources/Default-568h@2x.png differ diff --git a/Leaves-Info.plist b/LeavesExamples/Resources/LeavesExamples-Info.plist similarity index 100% rename from Leaves-Info.plist rename to LeavesExamples/Resources/LeavesExamples-Info.plist diff --git a/Resources-iPad/MainWindow-iPad.xib b/LeavesExamples/Resources/MainWindow-iPad.xib similarity index 100% rename from Resources-iPad/MainWindow-iPad.xib rename to LeavesExamples/Resources/MainWindow-iPad.xib diff --git a/Resources/MainWindow.xib b/LeavesExamples/Resources/MainWindow.xib similarity index 100% rename from Resources/MainWindow.xib rename to LeavesExamples/Resources/MainWindow.xib diff --git a/Resources/kitten.jpg b/LeavesExamples/Resources/kitten.jpg similarity index 100% rename from Resources/kitten.jpg rename to LeavesExamples/Resources/kitten.jpg diff --git a/Resources/kitten2.jpg b/LeavesExamples/Resources/kitten2.jpg similarity index 100% rename from Resources/kitten2.jpg rename to LeavesExamples/Resources/kitten2.jpg diff --git a/Resources/kitten3.jpg b/LeavesExamples/Resources/kitten3.jpg similarity index 100% rename from Resources/kitten3.jpg rename to LeavesExamples/Resources/kitten3.jpg diff --git a/Resources/paper.pdf b/LeavesExamples/Resources/paper.pdf similarity index 100% rename from Resources/paper.pdf rename to LeavesExamples/Resources/paper.pdf diff --git a/main.m b/LeavesExamples/main.m similarity index 94% rename from main.m rename to LeavesExamples/main.m index e60ad7e..e11d349 100644 --- a/main.m +++ b/LeavesExamples/main.m @@ -1,6 +1,6 @@ // // main.m -// Leaves +// LeavesExamples // // Created by Tom Brow on 4/18/10. // Copyright Tom Brow 2010. All rights reserved. diff --git a/Leaves_Prefix.pch b/Leaves_Prefix.pch deleted file mode 100644 index 27dbce8..0000000 --- a/Leaves_Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the 'Leaves' target in the 'Leaves' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/README.markdown b/README.markdown index e55e2be..79864ef 100644 --- a/README.markdown +++ b/README.markdown @@ -1,52 +1,60 @@ #Leaves -Leaves is an simple way to present a page-turning interface similar to Apple's iBooks. It comprises two classes, `LeavesView` and `LeavesViewController`, and occupies less than 100 kB compiled. It uses only public APIs, sacrificing a portion of iBooks' visual flair to ensure that your application is safe for submission to the App Store. +Leaves is an animated interface for navigating through a sequence of images +using page-turning gestures. As of iOS 5, Leaves is mostly obsoleted by +[UIPageViewController]. -Leaves supports: +Leaves requires iOS 3.0 or later. -- Text, images, PDFs -- anything that can be rendered in a graphics context -- Drag or tap to turn the page -- iPad- and iPhone-sized display areas +##Installation -Leaves does *not* currently support: +1. Add the files in the `Leaves` subdirectory to your Xcode project. +2. Ensure that your target links against `QuartzCore.framework`. -- Interactive elements on the page -- Swipe gestures -- Two-page landscape view +##Usage -Leaves requires iPhone OS 3.0 or later. +Creating a page-turning view controller is as simple as subclassing +[LeavesViewController][]: -#Installation + #import "LeavesViewController.h" -Add the files in the `Leaves` subdirectory to your Xcode project and ensure that you are linking against `QuartzCore.framework`. + @interface ColorSwatchViewController : LeavesViewController + @end -#Getting Started +...and implementing the [LeavesViewDataSource][LeavesView] protocol: -Creating a page-turning interface is as simple as subclassing `LeavesViewController`: + @implementation ColorSwatchViewController - @interface ColorSwatchViewController : LeavesViewController - @end + - (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView { + return 10; + } -...and implementing the `LeavesViewDataSource` protocol: + - (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)context { + CGContextSetFillColorWithColor( + context, + [[UIColor colorWithHue:index/10.0 + saturation:0.8 + brightness:0.8 + alpha:1.0] CGColor]); + CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx)); + } - @implementation ColorSwatchViewController + @end - - (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView { - return 10; - } +You may also use [LeavesView] directly. For more examples, see the included +`LeavesExamples` project. - - (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx { - CGContextSetFillColorWithColor(ctx, [[UIColor colorWithHue:index/10.0 - saturation:0.8 - brightness:0.8 - alpha:1.0] CGColor]); - CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx)); - } +##Forks +* [Two-page view](https://github.com/ole/leaves/tree/twopages) by [ole](https://github.com/ole) ([blog post](http://oleb.net/blog/2010/06/app-store-safe-page-curl-animations/)) +* [Zooming](https://github.com/hammerlyrodrigo/leaves) by [hammerlyrodrigo](https://github.com/hammerlyrodrigo) +* [ARC](https://github.com/tjboudreaux/leaves) by [tjboudreaux](https://github.com/tjboudreaux) +* [Retina support](https://github.com/Vortec4800/leaves) by [Vortec4800](https://github.com/Vortec4800) - @end +## Articles +* [App Store-safe Page Curl animations](http://oleb.net/blog/2010/06/app-store-safe-page-curl-animations/) +* [How To Add A Slick iBooks Like Page Turning Effect Into Your Apps](http://maniacdev.com/2010/06/lick-ibooks-like-page-turning-effect) +* [Building an iPad Reader for _War of the Worlds_](http://mobile.tutsplus.com/tutorials/iphone/building-an-ipad-reader-for-war-of-the-worlds/) -For more sophisticated examples, build the Xcode project included with Leaves. - -#Notes - -The best way to get an answer to your question about programming with Leaves is the [Leaves Developers mailing list](http://groups.google.com/group/leaves-developers), which I keep an eye on. But if you find a bug, be sure to visit the [tracker](http://github.com/brow/leaves/issues) or message me directly. \ No newline at end of file +[UIPageViewController]: https://developer.apple.com/library/ios/documentation/uikit/reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html +[LeavesViewController]: https://github.com/brow/leaves/blob/master/Leaves/LeavesViewController.h +[LeavesView]: https://github.com/brow/leaves/blob/master/Leaves/LeavesView.h