0
votes

I've been researching this problem all day and haven't found a suitable solution as yet.

I am trying to create a view similar to Notifications Centre in iOS7. There is a UISegmentControl at the top, On tapping on any of the tabs take you to a different screen. Swiping left or right take you forward or back to the last screen.

I'm looking at implementing this in a UINavigationController that has a UIViewController embedded in it.

I tried to just perform a segue based on the selectedIndex of the UiSegmentControl. This worked okay but crashes when going from one tab to another in a random order. Also, I don't get the swipe to go back. I don't need to swipe to go forward - just back.

I want to go to three different views - which all use the same viewController class (As these views do the same thing.

I'm using storyboards and iOS7 only.

Does anyone have any ideas how this could be done?

2

2 Answers

0
votes

Follow this simple approach.

  • Have your UISegmentedControl in navigation bar with items as One, two, three.

  • Have a three UIView in your viewController as view1, view2, view3.

  • Set your UISegmentedControl's target method & set by default index 0 as selected & implement the method.

    [self.segmentedControl addTarget:self action:@selector(changeSegments:) forControlEvents: UIControlEventValueChanged];
    
    -(void) changeSegments:(UISegmentedControl *)segment {
        // set your views alpha depending upon your selection.
    
     }
    

Hope that helps.

0
votes

I think you should be using a UICollectionView for your different screens. That way you get swipe out of the box.

Then it's just a matter of linking the segmented control to the collection view.