为什么没有在我的UITabBarItem上调用didSelectItem?

时间:2016-06-30 15:12:21

标签: ios swift

如何选择标签栏上的项目?

这是我的代码

@IBOutlet var tabBar: UITabBar!
@IBOutlet var item: UITabBarItem!
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
    if item.tag == 0 {
        print("if this worktap 1")

        let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
        vc.setInitialText("Look at this !")
        vc.addURL(NSURL(string: "https://link.com"))
        presentViewController(vc, animated: true, completion: nil)
    }
    else {
        // code
    print("if this work tap 2")
    }
}

但是点击一个项目时没有任何反应。

1 个答案:

答案 0 :(得分:0)

相关问题