19 March 2015
  1. drag View Controller into Main.storyboard
  2. Editor -> Embed in -> Navigation Controller
  3. impl button press action

     @IBAction func toView2(sender : AnyObject){
         let view2 = storyboard.instantiateViewControllerWithIdenfifier("View2") as View2
         self.navigationController.pushViewController(view2, animated: true)
     }
    
  1. create View2 : UIViewController
  2. drag View Controller into Main.storyboard
  3. select View Controller set Custom Class
  4. impl button press action

     @IBAction func toView1(sender : AnyObject){
         self.navigationController.popToRootViewControllerAnimated(true)
     }
    
  1. add a Bar Button Item to View1 on Main.storyboard
  2. Ctrl+Drag form Bar Button Item to View2
  3. Action Segue choose show
  1. open Main.storyboard and click on the link connect two controller
  2. open Utilities and click on Attributes inspector
  3. give the segue a meaningful identifier
  4. 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: "")
             }
         }
     }
    


blog comments powered by Disqus