Change Tab view after certain time interval received as response from Server request

泄露秘密 提交于 2019-12-14 03:07:23

问题


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

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'.

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'.

I thought following way to implement:

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.?

Thanks a lot in advacnce.


回答1:


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.



来源:https://stackoverflow.com/questions/11242816/change-tab-view-after-certain-time-interval-received-as-response-from-server-req

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!