Describes a method for creating segue on a storyboard drag control.
First to translate the next segue
Source: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/UsingSegues.html
Definition: Segue represents a conversion (?) between two Viewcontroller in the storyboard file. A view controller's buttons, table rows, or gestures typically point to the B-View controller.
Trigger: Implemented by Uikit, you can use notifications to transfer data between A and B. Segue is triggered after the workflow is as follows
Provides Shouldperformseguewithidentifier:sender: method to abort the steps required for a jump, such as not creating new segue and B;
Provides Prepareforsegue:sender: method to transfer data.
Type: The original table as follows, a few segue difference is: Show is a b heap on a, detail with B replacement a,modally with a template display B,popover with B as the pop-up window.
Table 9-1Adaptive Segue Types
Segue type |
Behavior |
Show (Push) |
This segue displays the new content using the showViewController:sender: method of the target view controller. For more view controllers, this segue presents the new content modally over the source view controller. Some View controllers specifically override the method and use it to implement different behaviors. For example, a navigation controller pushes the new view controller onto its navigation stack. UIKit uses the targetViewControllerForAction:sender: method to locate the source view controller. |
show Detail (Replace) |
this segue displays the new con Tent using The showdetailviewcontroller:sender: method of the Target View Controller. This segue are relevant only for view controllers embedded inside A Uisplitviewcontroller object. With this segue, a split view controller replaces it second child View controller (the detail controller) with the new Co Ntent. Most other view controllers present the new content modally. uikit uses the targetviewcontrollerforaction:sender: method to locate the source view controller. |
Present modally |
This segue displays the view controller modally using the specified presentation and transition styles. The view controller that defines the appropriate presentation context handles the actual presentation. |
Present as Popover |
In a horizontally regular environment, the view controller appears in a popover. In a horizontally compact environment, the view controller is displayed using a Full-screen modal presentation. |
Steps
1. Select cell, Associate cell with B,segue type Select Selection Show (detail)
2. Overwrite the Prepareforsegue method in a corresponding controller
Class Acontroller:uiviewcontroller, Uitableviewdatasource,uitableviewdelegate {
// ...
At present there is only one segue, so there is no judgment Viewcontrollerid, the error is to learn how to distinguish
Override Func Prepareforsegue (Segue:uistoryboardsegue, sender:anyobject?) {
Let Index:int = (self.table.indexPathForSelectedRow?. Row)!
Let data:videosummary = Videosummaries[index]
Let View:bcontroller = Segue.destinationviewcontroller as! Videoviewcontroller
View.selectedvideo = Data
}
}
3. Add the Selectedvideo property to the controller that corresponds to B
Class Bcontroller:uiviewcontroller, Uitableviewdatasource,uitableviewdelegate {
var selectedvideo:videosummary! Notice the exclamation mark,
//...
}
Success.
iOS Development click Tableviewcell, Show Details