LoginSignup
10
7

More than 5 years have passed since last update.

[Swift] TabBarでタップするTabItemがタップされたらなんかしらの処理を入れたいとき

Posted at

TabBarControllerのCustom Classを設定

HogeViewControllerとします。

Tab Bar Item に Tag を設定

Screen Shot 2015-08-24 at 10.20.28.png

HogeViewControllerでTagの情報を取得して、処理を入れる

以下な感じでコードを追記します。

override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
        switch item.tag {
        case 1:
          println("foo")
        default:
          println("bar")
        }
    }
10
7
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
10
7