【问题标题】:how can i add buttons to my navigation controller toolbar,so that i can see them in all views如何将按钮添加到我的导航控制器工具栏,以便我可以在所有视图中看到它们
【发布时间】:2010-07-14 14:55:52
【问题描述】:

我有导航控制器,在主视图中。nib 我在工具栏上添加了两个按钮,我也应该在下一个视图中查看这些按钮,但我现在无法在下一个视图中看到这些按钮, 我必须在其中添加这些,以便我可以在任何视图中看到这些按钮或访问....

任何帮助表示赞赏...

【问题讨论】:

    标签: iphone toolbar button


    【解决方案1】:

    快速简便的方法是在推送之前为新视图控制器设置工具栏项。

    // Assuming self.toolbarItems is already set.
    UIViewController *newViewController = [[[UIViewController alloc] init] autorelease];
    
    [newViewController setToolbarItems:self.toolbarItems];
    
    [self.navigationController newViewController animated:YES];
    

    如果您发现在每次推送之前应用此方法很乏味,那么您可以将所有 UIViewController 实现子类化,并一劳永逸地设置它的工具栏。 :)

    【讨论】:

      【解决方案2】:

      您需要设置每个视图的 toolbarItems 属性。

      显示时,此工具栏获得 它当前的一组项目来自 活动的toolbarItems属性 视图控制器。当活动视图 控制器变化,导航 控制器更新工具栏项 匹配新的视图控制器, 动画新项目到位 在适当的时候。

      http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-06-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多