更新UITabBar视图? [英] Update UITabBar Views?

查看:55
本文介绍了更新UITabBar视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,使用工具栏上的按钮来调用视图,但是我将其切换为使用标签栏.

I have an application where I was using buttons on a toolbar to call up the views, but I am switching it over to using a tab bar.

使用按钮时,我在MainViewController.m中使用以下代码更新页面上的值,并且工作正常:

When using the buttons I was using the following code in MainViewController.m to update the values on the page and it was working just fine:

-(IBAction) loadSummaryView:(id) sender {
 [self clearView];
 [self.view insertSubview:summaryViewController.view atIndex:0];
 //Update the values on the Summary view
[summaryViewController updateSummaryData];
[summaryViewController calculateData];
}

但是,使用选项卡栏我无法弄清楚该怎么做.我尝试将所有必需的代码放入摘要视图" viewDidLoad中,并加载初始值,但是当我在另一个视图中更改它们时,它不会更新这些值.

However, with the Tab Bar I can not figure out how to do this. I tried putting all of the necessary code in the Summary Views viewDidLoad and it loads the initial values, but it will not update the values when I change them in another view.

感谢您的帮助.我对此有些陌生,所以请不要含糊不清,因为我可能不理解响应.

Any help is appreciated. I am a bit new at this, so please don't be cryptic as I may not understand the response.

谢谢.

推荐答案

通过将代码放在 viewDidLoad 中,仅当从笔尖加载视图时才会调用该代码.除非您的内存不足,否则此视图将在应用程序的生命周期内保持加载状态.

By placing your code in viewDidLoad, it will only be called when the view is loaded from the nib. Unless you're running low on memory, this view will remain loaded for the duration of the life of your app.

因此,如果您需要在每次视图出现时都更新值,请考虑将代码移至 viewWillAppear

So if you need to update values every time the view will appear, consider moving that code to an override of viewWillAppear

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    // your stuff goes here...
    [self updateSummaryData];
    [self calculateData];
}

这篇关于更新UITabBar视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆