9

我正在寻找对标签栏控制器提供的控制器进行一些控制器配置。是否有一个很好的拦截点,我可以将一些值传递给目标控制器,就像 prepareForSegue 方法一样?

非常感激。

4

1 回答 1

8

您可以通过 tabviewcontroller 的数组访问来自 tabview 的所有控制器。您可以直接在那里修改它们。如果您希望在用户看到特定内容之前更改某些内容,请设置委托并实现委托方法。(您可以简单地更改此方法中的 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
于 2012-06-04T01:29:27.007 回答