0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Swift】前の画面へ値の受け渡し(TabBarControllerがある場合)

Last updated at Posted at 2021-01-20

概要

こちらの記事を参考にアプリを作っていたところ、TabBarControllerの中に埋め込んだ場合の記事もあると便利かなぁと思ったので書きました。
画面構成

コード

.swift
let preTBC = self.presentingViewController as! UITabBarController
let preNC = preTBC.customizableViewControllers?[0] as! UINavigationController //何番目のTabか指定(今回は0番目)
let preVC = preNC.viewControllers[preNC.viewControllers.count - 1] as! PreviousViewController

/*

ここに値を渡すコード

*/

「TabBarController」 → 「NavigationController」 → 「一つ前の画面」の順に定義していく感じです。

参考

【Swift】前の画面への値の受け渡し方

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?