Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 75

Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
07/23/15 07:32 AM (8 years ago)

Swipe between views code snippet

For those of you that like to work with nib files (old school) and want to swipe between views, I've been playing with a very simple code snippet that works perfectly. This would work well for images, books, anything you like. .h - (void)handleSwipeUp; (This could be down left and right with simple adaption) .m -(void) handleSwipeUp { myViewController *screen = [[myViewController alloc] initWithNibName:nil bundle:nil]; screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:screen animated:YES]; [screen release]; } -(void)viewDidLoad { [super viewDidLoad]; UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUp)]; swipeUp.direction = UISwipeGestureRecognizerDirectionUp; [self.view addGestureRecognizer:swipeUp]; } You can use the 4 different scrolls under this transition. Partial curl works brilliantly for books. Don't forget to #import the next view controller or the controller you want to transition to. Wonderfully simple. Enjoy!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/23/15 07:59 PM (8 years ago)
Nice, Thanks! Cheers! -- Smug
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
07/25/15 03:54 PM (8 years ago)
Great snippet! thanks
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
07/26/15 03:56 AM (8 years ago)
Thanks, bookmarked! Cheers, Alan
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.