0

参考我的问题,在收到服务器请求的响应后一定时间间隔后更改选项卡视图,我使用以下代码显示应用程序进入活动状态时的会话超时消息

AppDelegate.m 中的方法:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // to check the session
    XTabViewController *XTabViewCon = [[XTabViewController alloc] init];
    [XTabViewCon pushViewUponCheckedSession];
    [XTabViewCon release];
}

XTabViewController.m 中的方法

- (void)pushViewUponCheckedSession {
    //THIS IS VERY IMPORTANT. IT CHECKS FOR SESSION
    if ([[[ApplicationContext alloc] dataManager ] checkSession]) {
        [self showSessionAliveView];
        //here I can write something that will push a view that was seen last before leaving app to inactive state. May be NSNotification could help me
    }
    else {
        [self showSessionTimeOutView];
    }
}
- (void)showSessionTimeOutView {
    //show activity indi
    waitingIndicator = [[MyWaitingIndicator alloc]init];
    [self.view addSubview:waitingIndicator];
    [waitingIndicator setHidden:YES];
    [waitingIndicator stopAnimating];
    //push session timeout view
    SessionTimeOutViewController *sessionTimeOutView = [[SessionTimeOutViewController alloc] init];
    [[self navigationController] pushViewController:sessionTimeOutView animated:NO];
    [sessionTimeOutView release];
    [waitingIndicator release];
}

- (void)showSessionAliveView {
    SessionAliveView *sessionAliveViewList = [[SessionAliveView alloc] init];
    [[self navigationController] pushViewController:sessionAliveViewList animated:YES];
    [sessionAliveViewList release];
}

我的问题是:

pushViewUponCheckedSession当我在选项卡之间切换以检查会话是否过期时使用它时,它( )工作正常。

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    //if X Tab is selected then & only then call this method
    if (tabBarController.selectedIndex == 2) {
         [XTabViewCon pushViewUponCheckedSession];
    }

}

但它无法在checkedSession 上显示SessionTimeOutViewController 的视图 当应用程序进入活动状态时,我是否需要执行诸如刷新先前视图之类的操作。然后通过检查会话来填充适当的视图。

提前致谢

4

1 回答 1

0

Releasing XTabViewCon just after your method call is dangerous no ? You have to be sure that your aren't using your object before releasing it.

于 2012-07-02T08:39:32.720 回答