navigation use button -> view 2
- drag
View Controller
intoMain.storyboard
Editor
->Embed in
->Navigation Controller
-
impl button press action
@IBAction func toView2(sender : AnyObject){ let view2 = storyboard.instantiateViewControllerWithIdenfifier("View2") as View2 self.navigationController.pushViewController(view2, animated: true) }
navigation use button -> view 1
- create
View2 : UIViewController
- drag
View Controller
intoMain.storyboard
- select
View Controller
setCustom Class
-
impl button press action
@IBAction func toView1(sender : AnyObject){ self.navigationController.popToRootViewControllerAnimated(true) }
navigation use segue view 1 <β> view 2
- add a
Bar Button Item
toView1
onMain.storyboard
Ctrl+Drag
formBar Button Item
to View2Action Segue
chooseshow
navigation use segue customize back button
- open
Main.storyboard
and click on the link connect two controller - open
Utilities
and click onAttributes inspector
- give the segue a meaningful
identifier
-
open
parent view controller
and insert code// In a storyboard-based application, you will often want to do a little preparation before navigation override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. if let identifier = segue.identifier{ if identifier == "segue_setting"{ self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "θΏε", style: .Bordered, target: nil, action: "") } } }