简体   繁体   中英

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.

在此处输入图片说明

Here are different ways to create a segues:

1 - From Control To Controller:

从单元到细节控制器


2 - Using Connection Inspector

使用连接检查器


3 - From View Controller to View Controller

从View Controller到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:

在此处输入图片说明

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
    }
}

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM