10
7

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 5 years have passed since last update.

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

10
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?