0

I have view controller and implement like this :

loginViewController = [[LoginViewController alloc] init];
loginViewController.delegate = self;
[self.view addSubview:loginViewController.view];
[self addChildViewController:loginViewController];
[loginViewController didMoveToParentViewController:self];

Inside loginViewController, I want to show another view controller but I implement like this :

otherViewController = [[OtherViewController alloc] initWithNibName:nil bundle:nil];
otherViewController.delegate = self;
[self presentViewController:otherViewController animated:YES completion:nil];

Everytime I done with otherViewController and want to dismiss the view controller [self dismissViewControllerAnimated:YES completion:nil];

it restarted from the beginning and not showing the loginViewController. I tried to check using Debug View Hierarchy and got that no loginViewController is implemented when I called presentViewController:otherViewController

Why is this happened ?

victorz
  • 39
  • 1
  • 12
  • Do you use dismissViewControllerAnimated from inside otherViewController or login? – hasan May 03 '18 at 11:09
  • @hasan83 I using dismissViewControllerAnimated inside otherViewController – victorz May 03 '18 at 11:11
  • 1
    Please add the method you use to dismiss otherViewController – trungduc May 03 '18 at 11:49
  • can you check when you call presentViewController, does after it what view hierarchy methods calls like viewDidDisapper or dealloc method, because if dealloc is called then definitely its being released from somewhere. Please debug by adding breakpoints or adding comments in all the methods. – Surbhi Garg May 03 '18 at 12:36
  • @SurbhiGarg I tried to implement viewDidDisapper and dealloc method, and when I call otherViewController, it called viewDidDisapper inside loginViewController, not the dealloc method. – victorz May 04 '18 at 01:53
  • Is `[self presentViewController:otherViewController animated:YES completion:nil];` called from the same view controller where you add the `loginViewController`? – Ladislav May 04 '18 at 13:08

0 Answers0