TabBarController 是不是有像 prepareForSegue 这样的拦截点?

Posted

技术标签:

【中文标题】TabBarController 是不是有像 prepareForSegue 这样的拦截点?【英文标题】:Is there an interception point like prepareForSegue for the TabBarController?TabBarController 是否有像 prepareForSegue 这样的拦截点? 【发布时间】:2012-06-08 04:10:32 【问题描述】:

我希望通过标签栏控制器对呈现的控制器进行一些控制器配置。是否有一个很好的拦截点,我可以将一些值传递给目标控制器,就像 prepareForSegue 方法一样?

非常感谢。

【问题讨论】:

【参考方案1】:

标签视图中的所有控制器都可以通过标签视图控制器的数组进行访问。您可以直接在那里修改它们。如果您希望在用户看到特定内容之前更改某些内容,请设置委托并实现委托方法。 (你可以简单地改变这个方法里面的vc并返回yes)

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html

tabBarController:shouldSelectViewController:

Asks the delegate whether the specified view controller should be made active.
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController Parameters

tabBarController

    The tab bar controller containing viewController. viewController

    The view controller belonging to the tab that was tapped by the user.

Return Value

YES if the view controller’s tab should be selected or NO if the current tab should remain active. Discussion

The tab bar controller calls this method in response to the user tapping a tab bar item. You can use this method to dynamically decide whether a given tab should be made the active tab. Availability

    Available in iOS 3.0 and later.

Declared In UITabBarController.h

【讨论】:

如果选项卡以编程方式更改,则不会调用此方法。

以上是关于TabBarController 是不是有像 prepareForSegue 这样的拦截点?的主要内容,如果未能解决你的问题,请参考以下文章

javascript,是不是有像 isArray 这样的 isObject 函数? [复制]

木材是不是有像 404 一样的默认 500 模板?

javascript 是不是有像堆栈和队列这样的对象/容器? [复制]

SQLDeveloper 是不是有像 Toad 这样的复制/克隆用户的工具?

获取当前控制器(如果是在tabbarController中也能正确的获得当前控制器,而不是tabbarController)

IE8 是不是有像 6 或 7 这样的渲染错误?