I have a tab controller which is displaying my home screen. In my home screen, there are optional filters for my collection view there. I would like the filters to be reset if the user taps on the same tab bar button. Currently, tapping on the tab bar button doesn't do anything if you are already in the same view of the tab bar button. How can I execute code if the tab bar button was tapped a second time?
Asked
Active
Viewed 421 times
1
-
I don't know any easy and elegant way to achieve what you want. Perhaps you could add an invisible button over the active tab? BTW you should try to formulate your question so that it expresses a clear question which can be given an answer. You shouldn't ask for opinions or ideas. – Matti Jokipii Jul 21 '15 at 12:10
1 Answers
0
Try this method in a UITabBarController subclass or put tabbar delegate in your controller.
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
var isStatusbarWhite = false
for xx in (tabBar.items as! [UITabBarItem]){
for var i:Int = 0 ; i < self.tabBar.items?.count ; ++i {
let xx = tabBar.items![i] as! UITabBarItem
if (xx == item){
if tabBarController.selectedIndex == i {
//YOUR CODE HERE SAME TAB SELECTED
}
}
}
}

Elto
- 420
- 3
- 11