首页 > 代码库 > [Stanford 2011] segue

[Stanford 2011] segue

From:view 6(00:17)

Knowledge Points:

1. The segue is the thing that made it so that it moved over to the other MVC.

2. How the segue gets set up?

    To create a segue,you hold down ctrl and drag from the button to the other View Controller.

    Segues always instantiate a view controller.You never segue to an existing view controller,one that‘s already sitting in the heap. Segues create a new view controller,always. And they do this because, thatis the model we want for memory management. We want MVCs to get created when they go on screen. And then when they go off-screen, unless there‘s back button that might go to them,they go away. And then if you were to press the graph button again they get recreated, so view controllers are somewhat ephemeral alright. They come into existence they‘re used on screen, and when they go off screen a lot of times they‘ll just go away. And that keeps the memory usage for our app low.

two important properties are (1)The identifier. That gives a name to this segue.And the reasons we want the name:One, in our code we can say, go do this segue,by name. Specify the name of a segue, it‘ll go do it. And also, when segues happen, we get to get involved, maybe preparing this newly created view controller beyond screen. And we identify what to do to prepare it by the name,the segue. So it‘s important to know the name of this segue.(2)The style. There‘s different styles of segues. "push style" means it‘s in a navigation controller.

3. How we create a UINavigationController in our storyboard(putting the segue into the navigationController)?

We‘ve defined the segue between them, then we should put them inside navigation controller.

Tip: If you double click on the background of your storyboard, it‘ll zoom out to show you more. Which you really need when you start building your whole app, and multiple MVCs, all segueing into each other. You wanna be able to see the whole thing, and so you can zoom out. You can also zoom out with these little things down on the bottom.

The arrow that‘s going into that view controller means that this is where the application starts. You can pick that arrow up with the mouse in Xcode to move it to another control. Or you can use a little switch in the Inspector in the right side. That says initial scene.

How we get this thing in navigation controller?  ans:  Xcode | Editor | Embed in | Navigation Controller, so another view controller‘s going to appear, a navigation controller. Notice that it‘s going to keep the arrow, it moves the arrow to itself. and Then it has a little pointer right after it,which is not a segue. This little pointer in between is a special little connection in Xcode, which is the rootViewController outlet of the UINavigationController. (The navigation controller have a pointer to the root view controller that‘s the first MVC that they display. So that‘s what the little thing is. )

 UINavigationController is as bellow:

[Stanford 2011] segue