我希望通过Tab Bar Controller对所提供的控制器进行一些控制器配置。是否有一个很好的拦截点,我可以将一些值传递给目标控制器,就像prepareForSegue方法一样?
非常感谢。
答案 0 :(得分:8)
tabview中的所有控制器都可以通过tabviewcontroller的数组访问。您可以直接在那里修改它们。如果您希望在用户看到特定内容之前更改某些内容,请设置委托并实现委托方法。 (您只需更改此方法中的vc并返回yes)
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