推送到另一个ViewController错误

时间:2014-05-31 09:11:22

标签: ios uinavigationcontroller pushviewcontroller

在我的应用中,我实现了访问令牌逻辑。登录后,在我的仪表板的ViewDidLoad中,我正在调用Web服务来获取业务列表。在

  • (void)connectionDidFinishLoading:(NSURLConnection *)connection

方法,解析值。如果AT标签(访问令牌)过期(我将获得一个msg'访问令牌无效),我想调用登录​​页面(会话已过期)。但我在控制台中收到错误

开始/结束外观转换的不平衡调用。

控制权仍在我的仪表板中。

NSString *OSString = [jsonMain valueForKey:@"OS"];
    NSString *errorString = [jsonMain valueForKey:@"EM"];

    if([OSString isEqualToString:@"Success"])
    {
       // other parsing stuff
    }
    else
    {
        if([errorString isEqualToString:@"Access Token is invalid"])
        {
            appDelegate.loginMsgStr = @"Session Expired";

            Login *login = [[Login alloc] init];
            [self.navigationController pushViewController:login animated:YES];
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert!"
                                                            message:errorString
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
            [alert show];
        }
    }

2 个答案:

答案 0 :(得分:0)

如果您使用的是故事板,请使用

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    Login * login = (Login *)[storyboard instantiateViewControllerWithIdentifier:@"Loginview"];
    [self.navigationController pushViewController:login animated:YES];

如果您使用自定义导航,请使用

Login *login=[[Login alloc]initWithNibName:@"Login" bundle:[NSBundle mainBundle]];
     [self.navigationController pushViewController:login animated:YES];

答案 1 :(得分:0)

如果LoginView是您的RootViewController,请在

中使用此代码
  

(void)connectionDidFinishLoading:(NSURLConnection *)connection

方法:

  

[self.navigationController popToRootViewControllerAnimated:YES];

如果这项工作,请告诉我。

干杯。

相关问题