how to turn pages ? :)

Discussion in 'iOS Programming' started by nacho4d, Oct 19, 2008.

  1. nacho4d macrumors newbie

    Jul 13, 2008
    Hi everyone.
    I would like to give my UIViews the "turning pages" (maybe more like tearing off a newspaper from the corner or something like google maps application toolbar's right button but completely turn the page) effect.

    Any thoughts?
    I don't know where to begin to read. Maybe Core Animation? Transitions? OpenGL ES? .
    If someone could give some advices about what Classes to use or maybe useful methods, It would be awesome.
    Thanks in advance.:)
  2. jstanier macrumors regular


    Sep 6, 2008
    Brighton, England.
    Apologies for the massive chunk of code, but it should be fairly readable. When the method is called it toggles between two views, using page curl up and curl down. I think I got this code from one of the Apple code samples a very long time ago, but I can't remember which one.

    With regards to the "partial" curl up that Google Maps does, I don't know how to do that - never found out!

    -(void)toggleView {
    		 This method is called when the info or Done button is pressed.
    		 It flips the displayed view from the main view to the flipside view and vice-versa.
    		if (infoViewController == nil) {
    			[self loadInfoViewController];
    		UIView *mainView = imageViewController.view;
    		UIView *flipsideView = infoViewController.view;
    		[UIView beginAnimations:nil context:NULL];
    		[UIView setAnimationDuration:1];
    		[UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown) forView:self.view cache:YES];
    		if ([mainView superview] != nil) {
    			[infoViewController viewWillAppear:YES];
    			[imageViewController viewWillDisappear:YES];
    			[mainView removeFromSuperview];
    			[self.view addSubview:flipsideView];
    			[imageViewController viewDidDisappear:YES];
    			[infoViewController viewDidAppear:YES];
    		} else {
    			[imageViewController viewWillAppear:YES];
    			[infoViewController viewWillDisappear:YES];
    			[flipsideView removeFromSuperview];
    			[self.view addSubview:mainView];
    			[infoViewController viewDidDisappear:YES];
    			[imageViewController viewDidAppear:YES];
    			[infoViewController release];
    			infoViewController = nil;
    		[UIView commitAnimations];
  3. nacho4d thread starter macrumors newbie

    Jul 13, 2008

    I haven't try it ,if it is from apple samples it should be correct.

    This is exactly what I was looking for, not exactly the parcial one, because I want to swap the my views so completely curl up is what I was looking for!.

    Thanks again.:)

Share This Page