【问题标题】:Add button to top UITabBarController将按钮添加到顶部 UITabBarController
【发布时间】:2013-10-24 19:07:34
【问题描述】:

我有一个应用程序,它有一个 UITabBarController 作为 rootviewcontroller。 UITabBarController 有四个项目。四个 UIViewConotroller 嵌入在 UINavigationControllers 中。我可以在 UINavigationController 上添加按钮或图像。但是,对于同一个按钮或图像,我必须在每个 UINavigationController 上重复 4 次。是否可以在设置为 rootviewcontroller 的 UITabBarController 顶部添加按钮或图像?提前致谢。

【问题讨论】:

    标签: iphone objective-c ipad ios6


    【解决方案1】:

    理论上,你可以这样做:

    UIButton *button = ; // your button
    button.frame = CGRect(...); // position on the screen, where you want to have the button
    
    [rootViewController addSubview:button];
    

    但是,强烈不推荐这种解决方案。

    您可以做的是创建一个抽象类MyViewControllerWithButton : UIViewController,它将实现viewDidAppear: 创建UIButton 并将其添加到导航栏。

    您在标签栏中使用的所有视图控制器都将是 MyViewControllerWithButton 的子类。

    【讨论】:

      猜你喜欢
      • 2011-02-10
      • 2017-12-28
      • 2011-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 1970-01-01
      • 2016-11-14
      相关资源
      最近更新 更多