开发者

Where to put code that needs to be executed every time a Tableview (tab bar item) is selected

I would like to fill an array from a file every time one of my tableview's is selected开发者_C百科 in the tab bar.

I dont think putting the code in the viewDidLoad method works, because the view gets loaded on once?

Where should the code be placed?

Within the viewDidAppear method?


Put it in viewWillAppear if you want the code to run before the view is displayed.


You can conform to the UITabBarDelegate protocol and implement the following method:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

I suggest that you set the tag property in the creation of your UITabBarItems in order to differentiate between which tab the item is.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜