简体   繁体   English

共享按钮作为 UITabBarController 上的标签栏项目,没有关联的控制器

[英]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).我有一个带有五个标签栏项目的 UITabBarController,其中一个是分享按钮操作(分享 iTunes 商店链接 - 告诉朋友)。 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.我的问题是当我单击此选项卡时,UIActivityViewController 已显示为空白控制器,我需要显示共享窗口 (UIActivityViewController) 以显示在选择的最后一个选项卡栏视图上方以避免此选项卡栏项的空白视图。

You can implement the UITabBarControllerDelegate protocol and use the - tabBarController:shouldSelectViewController: method to intercept the tap on the share tab like this:您可以实现UITabBarControllerDelegate协议并使用- tabBarController:shouldSelectViewController:方法拦截共享选项卡上的点击,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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