Reputation: 85
I'd like to add an action sheet that appears when tab bar center item is clicked. like in this example: this is how it shows when center item is clicked
i have added the tab bar from storyboard and its working fine. the hard part of it is how to keep the previous view and overlay the action sheet. thanks in advance.
Upvotes: 2
Views: 575
Reputation: 1102
use this delegate function to intercept tab selection
for swift 3
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if self.tabBarController.customizableViewControllers.index(of: viewController) == 2 {
//display action sheet
return false
}
return true
}
for objective c
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
//same logic above
}
Upvotes: 1
Reputation: 10199
You could simply create an empty view controller, and present the action sheet in viewDidAppear
. But you have to think of what to do (e.g. which view controller to display)
Upvotes: 0