0

In order not to make duplicate, I didn't ask until now and I was trying all day long. So I know it has been asked before, but none of them helped me. I'm having trouble with using storyboard and it is getting more and more confusing.

I found out on the internet that using segues and overriding the method performSegueWithIdentifier:sender : would have me and I tried to that. I implemented that as:

- (IBAction)segmentChanged{
    if([segmentedControl selectedSegmentIndex] == 0)
        [self performSegueWithIdentifier:@"Doviz" sender:self];
    else
        [self performSegueWithIdentifier:@"Altin" sender:self];
}

Here is my storyboard:

Please note that I'm connecting with push method rather than embed, modal and custom, and connecting them not to the segmentedController but to the view. Maybe there might be also something wrong. Lastly, when I'm trying to running my application, I took the error:

Could not find a navigation controller for segue 'Altin'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.

I'm new and learning Xcode 'til 1 week, so I'll be much appreciated if you can give me an detailed answer on this.

Kutay Demireren
  • 640
  • 1
  • 10
  • 25

1 Answers1

0

Setup your storyboard so it looks like this:

enter image description here

An ensure to give each segue the appropriate identifier in the Attributes Inspector (Command+Option+4).

Please bare in mind that using a segmented control for pushing on view controllers isn't a standard UI paradigm. It may be more appropriate to use regular UIButton controls.

Steve Wilford
  • 8,894
  • 5
  • 42
  • 66
  • Sorry I deleted my comments, but I just realized it is not the way I wanted actually. I wanted to occur at the bottom of segmented controller, in that way it gives me a new page to show list. What should I use and how to connect? container maybe ? – Kutay Demireren Jun 22 '15 at 19:19
  • You could use a [UIPageViewController](https://developer.apple.com/library/ios//documentation/UIKit/Reference/UIPageViewControllerClassReferenceClassRef/index.html), though that might be a bit heavy, or use the view containment API. – Steve Wilford Jun 23 '15 at 06:30
  • Can u show / suggest me how to use containment API ? Two connected view to the one container is the first solution came to my mind. Is that correct? – Kutay Demireren Jun 23 '15 at 07:10
  • They wouldn't both be connected at the same time, instead you would need to swap them out when interacting with the segmented control. This [question & answer](http://stackoverflow.com/questions/19162874/swapping-child-views-in-a-container-view) is what you're looking for. – Steve Wilford Jun 23 '15 at 07:46
  • Okay I'll look at it after I'm done with my current work. Thanks you very much ! – Kutay Demireren Jun 23 '15 at 07:56