在收到服务器请求的响应后的特定时间间隔后,更改选项卡视图 [英] Change Tab view after certain time interval received as response from Server request

查看:132
本文介绍了在收到服务器请求的响应后的特定时间间隔后,更改选项卡视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有UITabBarController的应用程序中,我想实现以下情形:

In an application having UITabBarController, I want to implement following scenario:

用户在"X"标签上时,他/她会执行某项操作&然后移至另一个标签.然后他/她再次返回"X"标签(在5分钟后说->这很重要,因为我将来可能将5min更改为10min ),然后我想显示一些信息,例如您的会话"已过期".

When user is on 'X' Tab, he/she does something & then move to another tabs. And again he/she comes back to 'X' tab(say after 5minutes-> this is important as I may change 5min to 10min in future), then I want to show some message like your 'Session is expired'.

每当用户返回"X"选项卡时,都需要发出服务器请求以获取响应代码.取决于显示的是会话已过期"弹出窗口.

Whenever user comes back 'X' Tab, it need to make server request to get response code. Depending upon that I want to show the pop-up 'Session is expired'.

我想过以下实现方式:

在将所有视图加载到UITabBarController"X"标签的每个viewWillAppear:方法中,我将向服务器发出请求&检查响应和相应地执行操作.

In every viewWillAppear: method of all views being loaded inside 'X' Tab viewController of UITabBarController I will make server request & check for response & perform operations accordingly.

但这将涉及许多我希望避免的服务器请求.

But it will involve many server request which I want to avoid.

我无法得出结论.我怎么能达到我的要求??

I am not able to conclude with solution. How can I achieve my requirement.?

非常感谢你们.

推荐答案

您只需要在标签栏委托方法中执行一次-

You need to perform this only once in tab bar delegate method -

- (void)tabBarController:(UITabBarController *)tabBarController 
    didSelectViewController:(UIViewController *)viewController

在这种基于标签索引的方法中,您可以拥有代码,而无需在多个视图控制器中编写代码.

Inside this method based upon the tab index you can have your code, you won't need to write the code in several view controllers.

这篇关于在收到服务器请求的响应后的特定时间间隔后,更改选项卡视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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