【问题标题】:Show a UIPopover on Tab Bar Controller buttons/icons在标签栏控制器按钮/图标上显示 UIPopover
【发布时间】:2014-02-07 14:16:33
【问题描述】:

我的应用程序使用带有故事板的标签栏控制器。在第一次通过应用程序时,我想在每个选项卡栏按钮上使用 UIPoppver。但是,要做到这一点,我需要知道每个(我认为)的 CGRect 。我该怎么做?

【问题讨论】:

标签: ios7 uitabbarcontroller xcode5 uipopovercontroller


【解决方案1】:

感谢上面提供的链接,这是我解决这个问题的方法:

在我的 AppDelegate.h 中

添加:

- (NSMutableArray *)tabBarMutableArray;

在我的 AppDelegate.m 中

添加:

- (NSMutableArray *)tabBarMutableArray;
{
    UITabBarController *tabController           = (UITabBarController *)self.window.rootViewController;
    NSMutableArray     *tabBarItemsMutableArray = [NSMutableArray new];

    UITabBar *tabBar = tabController.tabBar;

    for (UIView *view in tabBar.subviews)
    {
        [tabBarItemsMutableArray addObject:view.description];
    }

    return  tabBarItemsMutableArray;
}

现在我可以在任何地方访问该值:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Array AppDelegate: %@", [appDelegate tabBarMutableArray]);

结果:

"<_UITabBarBackgroundView: 0x145e19f70; frame = (0 0; 1024 56); autoresize = W; userInteractionEnabled = NO; layer = <CALayer: 0x1700359c0>>",
"<UITabBarButton: 0x145e15950; frame = (254 1; 76 55); opaque = NO; layer = <CALayer: 0x17002a9a0>>",
"<UITabBarButton: 0x145e19dd0; frame = (364 1; 76 55); opaque = NO; layer = <CALayer: 0x1700345c0>>",
"<UITabBarButton: 0x145d0f8a0; frame = (474 1; 76 55); opaque = NO; layer = <CALayer: 0x17803cc60>>",
"<UITabBarButton: 0x145e1a360; frame = (584 1; 76 55); opaque = NO; layer = <CALayer: 0x1700348e0>>",
"<UITabBarButton: 0x145e1a940; frame = (694 1; 76 55); opaque = NO; layer = <CALayer: 0x170034c60>>",
"<UIImageView: 0x145e1a090; frame = (0 -0.5; 1024 0.5); autoresize = W; userInteractionEnabled = NO; layer = <CALayer: 0x1700369e0>>"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-22
    • 1970-01-01
    • 2019-10-14
    相关资源
    最近更新 更多