how to turn pages ? :)

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

  1. nacho4d macrumors newbie

    Joined:
    Jul 13, 2008
    #1
    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.:)
    Ignacio.
     
  2. jstanier macrumors regular

    jstanier

    Joined:
    Sep 6, 2008
    Location:
    Brighton, England.
    #2
    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!

    Code:
    -(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

    Joined:
    Jul 13, 2008
    #3
    Thanks

    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