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

Sla*_*ppy 9 model-view-controller uitabbarcontroller ios

我希望通过Tab Bar Controller对所提供的控制器进行一些控制器配置.是否有一个很好的拦截点,我可以将一些值传递给目标控制器,就像p​​repareForSegue方法一样?

非常感激.

Poc*_*chi 8

tabview中的所有控制器都可以通过tabviewcontroller的数组访问.您可以直接在那里修改它们.如果您希望在用户看到特定内容之前更改某些内容,请设置委托并实现委托方法.(你可以简单地改变这个方法中的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
Run Code Online (Sandbox Code Playgroud)