Upgrade to Pro — share decks privately, control downloads, hide ads and more …

もっと早く教えて欲しかった画面遷移

 もっと早く教えて欲しかった画面遷移

PKPK-Carnage

January 22, 2019
Tweet

More Decks by PKPK-Carnage

Other Decks in Programming

Transcript

  1. About me • iOSྺ2೥ͪΐͬͱ • Qiita → @PKPK-Carnage • Github

    → PKPK-Carnage • Twitter → @PKPK-Carnage
  2. 7

  3. 8

  4. 9 extension HogeViewController { @IBAction private func didTapFugaButton(_ sender: UIButton)

    { self.performSegue(withIdentifier: "showFuga", sender: sender.tag) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let vc = segue.destination as? FugaViewController { if let value = sender as? Int { vc.value = value } } } }
  5. 11

  6. 12

  7. 13 extension HogeViewController { @IBAction private func didTapFugaButton(_ sender: UIButton)

    { self.performSegue(withIdentifier: "showFuga", sender: sender.tag) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let vc = segue.destination as? FugaViewController { if let value = sender as? Int { vc.value = value } } } }
  8. 14 extension HogeViewController { @IBAction private func didTapFugaButton(_ sender: UIButton)

    { self.performSegue(withIdentifier: "showFuga", sender: sender.tag) } @IBAction private func didTapPiyoButton(_ sender: UIButton) { self.performSegue(withIdentifier: "showPiyo", sender: sender.currentTitle) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let vc = segue.destination as? FugaViewController { if let value = sender as? Int { vc.value = value } } else if let vc = segue.destination as? PiyoViewController { if let value = sender as? String { vc.value = value } } } }
  9. (PPE #BE • ભҠΛࢹ֮తʹݟΕΔ • ؆୯ʹ࣮૷Ͱ͖Δ 22 • ը໘਺͕૿͑ΔͱΧΦε •

    ίϯϑϦΫτͰઈ๬͢Δ • identifierͰભҠઌΛࢦఆ͠ͳ͚ Ε͹ͳΒͳ͍ • prepareϝιου͕ѻ͍ͮΒ͍
  10. 24 extension HogeViewController { @IBAction private func didTapFugaButton(_ sender: UIButton)

    { self.performSegue(withIdentifier: "showFuga", sender: sender.tag) } }
  11. 25 extension HogeViewController { @IBAction private func didTapFugaButton(_ sender: UIButton)

    { let vc = FugaViewController(nibName: "FugaViewController", bundle: .main) vc.value = sender.tag self.navigationController?.pushViewController(vc, animated: true) } }
  12. (PPE #BE • ஋౉ָ͕͠ʹͰ͖Δ • ίϯϑϦΫτͯ͠΋௚͠΍͍͢ • segueΑΓ҆৺ 32 •

    ભҠΛࢹ֮తʹݟΕͳ͘ͳΔ • Ͳͷը໘ʹભҠ͢Δ͔೺Ѳ͢Δ ͷ͕େม • ॲཧΛॻ͘ͷ͕໘౗
  13. ભҠ͢ΔͨΊͷprotocolΛ࡞Δ 36 protocol FugaTransitable: class { func transitToFuga(value: Int) }

    extension FugaTransitable where Self: UIViewController { func transitToFuga(value: Int) { let vc = FugaViewController(nibName: "FugaViewController", bundle: .main) vc.value = value self.navigationController?.pushViewController(vc, animated: true) } }
  14. ભҠͷprotocolΛ௥Ճ͍ͯ͘͠ 38 extension HogeViewController: FugaTransitable, PiyoTransitable { @IBAction private func

    didTapFugaButton(_ sender: UIButton) { self.transitToFuga(value: sender.tag) } }