aherrick
aherrick

Reputation: 20179

iOS 7 XCode 5 Storyboard Layout Example

I'm trying to create a dead simple storyboard app with a layout similar to the following. I've got the list/detail view setup but I can't figure out how to link additional pages. I want the "go" page to be my start page and drive off that.

Can someone help me with a dead simple example solution on how you would set this up? I'm trying to use "push" segues.

enter image description here

Upvotes: 0

Views: 397

Answers (3)

meda
meda

Reputation: 45500

Here are different ways to create a segues:

1 - From Control To Controller:

From Cell To detail Controller


2 - Using Connection Inspector

Using Connection Inspector


3 - From View Controller to View Controller

From View Controller to View Controlle!


  • #1 and #3 you will need to hold control before dragging.
  • #2 & #3 : You will need to give an identifier to your segue, unlike #1 You have to performe the segue using code:

add identifier:

enter image description here

Perform the segue:

[self performSegueWithIdentifier:@"yourSegue" sender:sender];

Now here is the thing, this will just perform the segue, if you ever needed to pass some data to that view controller. Then you have to implement the following segue deleguate:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"yourSegue"])
    {
        //if you need to pass data to the next controller do it here
    }
}

Upvotes: 2

Stefano Mondino
Stefano Mondino

Reputation: 1219

Push segues will not work until you embed your view controller hierarchy in a UINavigationController. You can place one as root view controller for your GO view controller and then it should work

Upvotes: 1

Stefan
Stefan

Reputation: 5461

You can do this for example by ctrl click on a button and then move the mouse to your target view controller and release.

I've created a very simple example in my blog:

http://stefansdevplayground.blogspot.de/2014/02/howto-add-view-controllers-to.html

Upvotes: 0

Related Questions