Git Product home page Git Product logo

leaves's Introduction

#Leaves

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 requires iOS 3.0 or later.

##Installation

  1. Add the files in the Leaves subdirectory to your Xcode project.
  2. Ensure that your target links against QuartzCore.framework.

##Usage

Creating a page-turning view controller is as simple as subclassing LeavesViewController:

#import "LeavesViewController.h"

@interface ColorSwatchViewController : LeavesViewController 
@end

...and implementing the LeavesViewDataSource protocol:

@implementation ColorSwatchViewController

- (NSUInteger)numberOfPagesInLeavesView:(LeavesView*)leavesView { 
    return 10;
}

- (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));
}

@end

You may also use LeavesView directly. For more examples, see the included LeavesExamples project.

##Forks

Articles

leaves's People

Contributors

brow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaves's Issues

Zoom in and Rotate the device and then double tap

When I zoom in the pdf and then rotate to landscape to portrait or portrait to landscpae and the double tap to go to the actual size of the PDF, it shows the blank white space in the PDF.
Please let me know if I can fix this issue.

Thanks,
UPT

Could not run Sample Project

leaves_error

Hi,
I could not able to run your sample project and even, i tried to build new project by added leaves folder and adding QuartzCore.framework. I have attached image,

thanks

Page turn showing up but no pdf in view?

I added the code to my xcode project. When I go to the view where my .pdf is suppose to be in the simulator, the pdf does not show up. I can swipe the pages (the animation swipe works) but I'm swiping blank pages. Anyone have any idea on what I could be doing wrong?

Any help would greatly be appreciated.

Thanks alot

Is it possible to create new view design in Leaves View

I design a quotes app.All quotes are loaded in table view,When i click a table cell,Each quotes are loaded in leaves view with one by one.Then turn next page ,next quotes should be displayed in next page.Kindly answer my question.

Crashes on iPad

I modified a version of this to use with an app on the iPad. It would work in the simulator, but crashed on the iPad. I found that the problem was that the CGImageRef was being released, then passed back in - (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex. Also there was a call to [UIImage imageWithCGImage:] that was not needed. Here is what my code now looks like

  • (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex {
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(NULL,
    pageSize.width,
    pageSize.height,
    8, /* bits per component_/
    pageSize.width * 4, /_ bytes per row */
    colorSpace,
    kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
    CGColorSpaceRelease(colorSpace);
    if (context == nil) {
    //NSLog(@"Failed to create context for pageIndex=%d", pageIndex);
    return nil;
    }
    CGContextClipToRect(context, CGRectMake(0, 0, pageSize.width, pageSize.height));
    [dataSource renderPageAtIndex:pageIndex inContext:context];
    CGImageRef image = CGBitmapContextCreateImage(context);
    CGContextRelease(context);

    // REMOVED THE FOLLOWING TWO LINES
    // [UIImage imageWithCGImage:image]; // ?? serves no purpose
    // CGImageRelease(image); // releases image then passes it back to caller

    return image;
    }

how to make the flipping left to right

i need to use the same here in right to left project like hebrew and arabic so the pdf should flip from left to right not right to left like it happen now.. i tried to figure out how to make it but it's a bit confusing.. thanks sir for your effort anyway it helps me alot :)

Scanned PDF not rendering

Observed a weird issue. Scanned documents are not rendering. We can't see any content. But when we zoom in/out, we are able to see the content but content is upside down (90 degrees) to actual document.
Could you please help here.

How can you programmatically trigger a page turn?

I tried copying pieces of the code from the touchesEnded:withEvent: method, but only the forward page turn is working. Any way to do this? I basically want it to simulate the user touching the side of the screen. Thanks.

GO To Page

Is it possible to use some goto function or something like to show wanted pdf page?

Crash on ios7 while using images

I'm implementing leaves with Images. It was fine with upto ios6 but when I'm running this app in ios7 its going to crash. Following is the crash report of my app

2013-10-07 12:57:43.524 Books[1950:a0b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* setObjectForKey: object cannot be nil (key: 0)'
*** First throw call stack:
(
0 CoreFoundation 0x03c315e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x02c8f8b6 objc_exception_throw + 44
2 CoreFoundation 0x03cbb578 -[__NSDictionaryM setObject:forKey:] + 888
3 Books 0x0001c74d -[LeavesCache cachedImageForPageIndex:] + 317
4 Books 0x0000dbc6 -[LeavesView getImages] + 230
5 Books 0x00010bd0 -[LeavesView setCurrentPageIndex:] + 176
6 Books 0x0000dacb -[LeavesView reloadData] + 171
7 Books 0x00016774 -[LeavesViewController viewDidLoad] + 244
8 UIKit 0x00f909a8 -[UIViewController loadViewIfRequired] + 696
9 UIKit 0x00f90c44 -[UIViewController view] + 35
10 UIKit 0x00faaa72 -[UINavigationController _startCustomTransition:] + 778
11 UIKit 0x00fb7757 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
12 UIKit 0x00fb8349 -[UINavigationController __viewWillLayoutSubviews] + 57
13 UIKit 0x010f139d -[UILayoutContainerView layoutSubviews] + 213
14 UIKit 0x00ee7dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
15 libobjc.A.dylib 0x02ca181f -[NSObject performSelector:withObject:] + 70
16 QuartzCore 0x0200a72a -[CALayer layoutSublayers] + 148
17 QuartzCore 0x01ffe514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x01ffe380 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
19 QuartzCore 0x01f66156 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
20 QuartzCore 0x01f674e1 _ZN2CA11Transaction6commitEv + 393
21 QuartzCore 0x01f67bb4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
22 CoreFoundation 0x03bf953e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 30
23 CoreFoundation 0x03bf948f __CFRunLoopDoObservers + 399
24 CoreFoundation 0x03bd73b4 __CFRunLoopRun + 1076
25 CoreFoundation 0x03bd6b33 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x03bd694b CFRunLoopRunInMode + 123
27 GraphicsServices 0x035b99d7 GSEventRunModal + 192
28 GraphicsServices 0x035b97fe GSEventRun + 104
29 UIKit 0x00e7d94b UIApplicationMain + 1225
30 Books 0x0001c21d main + 125
31 libdyld.dylib 0x04ae6725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

And it's coming under following method

  • (CGImageRef) cachedImageForPageIndex:(NSUInteger)pageIndex {
    NSNumber *pageIndexNumber = [NSNumber numberWithInt:pageIndex];
    UIImage *pageImage;
    @synchronized (pageCache) {
    pageImage = [pageCache objectForKey:pageIndexNumber];
    }
    if (!pageImage) {
    CGImageRef pageCGImage = [self imageForPageIndex:pageIndex];
    pageImage = [UIImage imageWithCGImage:pageCGImage];
    @synchronized (pageCache) {
    [pageCache setObject:pageImage forKey:pageIndexNumber];
    }
    }
    return pageImage.CGImage;
    }

Retina Display Support

It looks like the contexts used in the cache only support a scale of 1.0 - I've been trying to set it to 2.0 when on the iPhone 4 but to no avail. I'm doing pretty standard drawing in the CGContextRef, but it doesn't seem to scale on its own. Is there something else I need to do, perhaps to some of the layers in Leaves?

ansani/Leaves project Landscape issue

Hi all,
I am working on leaves project for rendering images(applying page curl effect).I am successful in getting the page curl effect in Portrait Mode and unable to get two-page landscape view with two images side by side.could some one suggest me what should be done as landscape mode is locked when i rotate screen rotation.And also provide some sample project for getting two-page landscape view with images side by side.
Thanks for the assistance.

Regards,
kaushik

rendering pdf while zooming

Is there a way to render pdf during zooming? my pdf lose quality while zooming. I tried CATiledView but the iOS crashes due to memory fault.

context error on iOS 4.2

Hi! I'm debugging my application on iOS 4.2 GM seed, and I obtain the following error on the simulator console:

: CGContextClipToRect: invalid context 0x0
: CGContextGetClipBoundingBox: invalid context 0x0
: CGContextConcatCTM: invalid context 0x0
: CGContextDrawImage: invalid context 0x0
: CGBitmapContextCreateImage: invalid context 0x0
: CGContextClipToRect: invalid context 0x0
: CGContextGetClipBoundingBox: invalid context 0x0
: CGContextConcatCTM: invalid context 0x0
: CGContextDrawImage: invalid context 0x0
: CGBitmapContextCreateImage: invalid context 0x0

Error seems issued by LeavesCache.m on the following member function

  • (CGImageRef) imageForPageIndex:(NSUInteger)pageIndex

I just start to debug the application, so these are just my first impressions.

Hope to a fix soon, or maybe an hint to fix the so problem so I'll be able to commit the fix.

Thx,
Diego

flip only a subview.

i have a simple uiview hierarchy, a uiimageview for background and inside this view an uiimageview for display pages

how can i specify which uiview i need to animate?

thanks

too slow

I'm using rodrigo's leaves version and in iPad 5.0 it's too slow when changing the pages in landscape mode. Did anyone solve this?

Thanks in advance

Leak

Hi Brow, thanks for sharing your projects .

I tested your project in a real device (Iphone4) with 12 more images in the Image Example mode and I think uncache you are doing is not sufficient, the images are kept in memory in another step. If you run Instruments/Allocations you can see how the liveBytes grow until you have gone throw all the images. You can see some info about this object's allocation, like Responsible Library = ImageIO or Responsible Caller = ImageIO_Malloc. However I cant fix it so far ... your help would be really appreciate it.

Thanks

Pinch Zoom Issue - Two page viewing

Hi all,

we face an issue which has been not reported yet.
We deployed the application in to iPhone , in portrait mode the zooming doesn't work properly.

Right page overlaps the left page , but in iPad the issue is not occurring.

Regards

when i try a different PDF file and load it to iPad... it got..

*** _NSAutoreleaseNoPool(): Object 0x126460 of class NSCFData autoreleased with no pool in place - just leaking
Stack: XXXX...XX

the main.m is same as general. Only thing i do is try another PDF with 133 page and load it to my iPad. Anyone got the same problem..?

LeavesViewController does not use designated initializer of superclass UIViewController resulting in an infinite loop

The init method in the LeavesViewController is not using the designated initializer of the UIViewController superclass. As a result, an infinite loop results when a subclass of LeavesViewController is loaded from a NIB.

See the documentation for [NSObject init] where it discusses how to "prevent the possibility of an infinite loop" (http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/doc/uid/20000050-init).

I forked it to http://GitHub.com/Rob-S/leaves and used the same pattern for LeavesViewController that was already being used in LeavesView. I also submitted a "Pull Request" to "brow", but I'm not sure how that works or how to check on its status.

Thanks in advance.
Rob Simpson
http://Lnkd.com?24

error when zooming image

Hello,

I am getting an error when zooming the image view in the simulator. Is anyone else having this issue?

..joe..

Storyboard Delegate

xCode 4.6.3 created new project. When loading the app or changing orientation the page cache is not updated, resulting on load the first 3 pages are initially blank until you page to page 5, same with a change to orientation, but instead of blank I have the the previous orientation's pages.

Is there a delegate issue with stroryboards? I am using the original scene and the ViewController is a subclass of LeavesViewController.

Not supposrted for all PDFs

The code works well with certain PDFs but not with all PDF.
Here is the list of errors which comes when parsing the PDF and resulting in to an empty white page.

Errors :

FlateDecode: decoding error: incorrect header check.
invalid Contents': not a stream or array. missing or invalid arguments for color operator. stack underflow: popping past mark. fontF28' not found in document.
font `F168' not found in document.

Do any one has idea for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.