iPhoneアプリ Single View Application②

投稿者: | 2017年2月23日

Single View Application で複数画面のアプリを作る方法です

2画面間を遷移する簡単なサンプルです

Xcode 8 と Swift 3を使います

 

iPhoneアプリ Single View Application①の続きです

iPhoneアプリ Single View Application①

次は、2画面目から1画面目に戻る方法です

①1画面目のViewController.swiftに「unwind segue」を作成します

以下のメソッドをViewController.swiftに記述します


@IBAction func <メソッド名>(segue: UIStoryboardSegue) {
}

 

ViewController.swift

import UIKit

class ViewController: UIViewController {

     override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
     }

     override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
     }

     @IBAction func returnTop(segue: UIStoryboardSegue) {
     }
}
     

 

②2画面目の「Button」を2画面目のView Controllerの上にある一番右のアイコンに、
 右クリックしてドラッグします
 ドラッグするとメニューが表示されるので①で作成したメソッドを選択します
 

 

これで2画面目の「Button」をクリックすると、1画面目に戻るようになります

 
 

iPhoneアプリ Single View Application②」への1件のフィードバック

  1. ピンバック: iPhoneアプリ Single View Application① – memorandum

コメントは停止中です。