开发者

Call a method when switchig views with UITabBar

Is there any way to automatically call a custom method when switching views usig a UITabBarController? Like, I want to he able to, when I set a NSString in one view in a UILabel, haave it automatically 开发者_如何学JAVAupdate a different label on a different tab with the same string. Thank you!


Yes, take a look at the UITabBarControllerDelegate protocol. All you have to do is register your object as the tab bar delegate and implement the shouldSelect or didSelect callback (the didSelect would be better a better choice). The callback will get called each time the tab bar switches.


Take a look at tabBarController:didSelectViewController: in UITabBarControllerDelegate. Implement that method in your delegate and do whatever updating you need to do in there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜