navigation use button -> view 2
- drag
View ControllerintoMain.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 ControllerintoMain.storyboard - select
View ControllersetCustom 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 ItemtoView1onMain.storyboard Ctrl+DragformBar Button Itemto View2Action Seguechooseshow
navigation use segue customize back button
- open
Main.storyboardand click on the link connect two controller - open
Utilitiesand click onAttributes inspector - give the segue a meaningful
identifier -
open
parent view controllerand 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: "") } } }