I’m trying to detect a swipe gesture to switch between two .xib files. Right now the main file loads perfectly, but how do I make it so that on a swipe right it loads the second .xib file? They are both part of my project and created with the Interface Builder. For example purposes you could call them Page1 and Page2.
This is what I have so far:
- (void)createGestureRecognizers {
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe:)];
[self.theView addGestureRecognizer:swipe];
[swipe release];
}
- (IBAction)handleSwipe:(UIGestureRecognizer *)sender {
//What to put here?
}
I believe this should handle any swipe gesture and pass the selector to my handleSwipe method which should somehow change the viewController xib. Am I going about this correctly and if so, how can I switch the xib file in my handleSwipe method?
Have you considered a UIPageViewController? Either that or you could push a UIViewController(Page 2) onto the navigation stack upon side swipe and animate it(default animates right to left). This can be achieved by using a
UINavigationViewController