0
votes

Actually I have application which is using NavigationController (Xcode 4.6.2 with storyboard). I'm able navigating next/back views based on functionality delivered by standard NavigationController plus swipe gestures.

No I'm trying to add tab bar (finally it will be custom UI element) which will allow me change views. For example I want to skip from first view to third without swipe gestures, but only by taping tab on my bottom menu. I've tired to add TabBarController (in Xcode Editor -> Embed In -> Tab Bar Controller), but after that disappear on all my views navigation bar.

Do you have any suggestion how should I approach to this problem?

1

1 Answers

0
votes

You can use a uiswipegesturerecognizer, like so...

- (void)viewDidLoad
{
[super viewDidLoad];

UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tappedRightButton:)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipeLeft];

UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tappedLeftButton:)];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
[self.view addGestureRecognizer:swipeRight];
}

- (IBAction)tappedRightButton:(id)sender
{
      NSUInteger selectedIndex = [self.tabBarController selectedIndex];

[self.tabBarController setSelectedIndex:selectedIndex + 1];
}

- (IBAction)tappedLeftButton:(id)sender
{
NSUInteger selectedIndex = [self.tabBarController selectedIndex];

[self.tabBarController setSelectedIndex:selectedIndex - 1];
}

It's fairly simple, it should go into each view controller.