0

In my app, i have implemented an access token logic. After Login, in the ViewDidLoad of my dashboard, am calling a web service to get the list of businesses. In the

  • (void)connectionDidFinishLoading:(NSURLConnection *)connection

method, am parsing the values. If the AT tag(access token) is expired(i ll get a msg 'access token is invalid), i would like to call the login page(session expired). But i get the error in console

Unbalanced calls to begin/end appearance transitions for .

and the control remains in my dashboard.

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];
        }
    }
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mano
  • 670
  • 1
  • 9
  • 28
  • 2
    If you can show some code about what you are using or how you are trying to get back to the login page, then i can try and help. – try catch finally May 31 '14 at 09:13
  • At what point in you ViewControllers life-cycle do you do this? Does Login use .xib? Check this post http://stackoverflow.com/questions/6809593/unbalanced-calls-to-begin-end-appearance-transitions-for-firstviewcontroller-0 – andershqst May 31 '14 at 10:03

2 Answers2

0

If you are using storyboard then use

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

if you are using custom navigation then use

Login *login=[[Login alloc]initWithNibName:@"Login" bundle:[NSBundle mainBundle]];
     [self.navigationController pushViewController:login animated:YES];
Vibha Singh
  • 623
  • 4
  • 9
0

If LoginView is your RootViewController use this code in your

(void)connectionDidFinishLoading:(NSURLConnection *)connection

method:

[self.navigationController popToRootViewControllerAnimated:YES];

Do let me know if this work.

Cheers.

  • This link might also help to clear you doubt. http://stackoverflow.com/questions/9088465/unbalanced-calls-to-begin-end-appearance-transitions-for-detailviewcontroller – try catch finally May 31 '14 at 11:26
  • It didnot work frnd.. after using ur code, i didnt get that error in console but still control remains in the dashboard. It didn't go to login page. – Mano May 31 '14 at 18:50
  • If it remains in the same page you can try and debug using breakpoint and check where the login view is getting initialized or not. And can you tell me if the login view is already in the stack or you need to push to login view??? – try catch finally Jun 03 '14 at 10:16