简体   繁体   中英

share button as tab bar item on UITabBarController with no controller associated

I have a UITabBarController with five tab bar items, one of them is share button action (to share the itunes store link - tell a friend). My issue is when I click on this tab, the UIActivityViewController has displayed with blank controller, I need to show the share window (UIActivityViewController) to appear above the last tab bar view selected to avoid the blank view of this tab bar item.

You can implement the UITabBarControllerDelegate protocol and use the - tabBarController:shouldSelectViewController: method to intercept the tap on the share tab like this:

- (BOOL) tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    if (viewController == [tabBarController.viewControllers objectAtIndex:/*share button index*/]){
        //show UIActivityViewController
        return NO;
    }
    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM