AFAIK, if you add a UINavigationController to a UIView through code, it will not send these messages to it as subviews by default. This will only be done if the UINavigationController itself has received these calls. Perhaps this is your problem (I do not know your view setting).
So, adding the UINavigationController view, be sure to send it these messages manually.
UINavigationController *navigationController = [UINavigationController alloc] initWithRootViewController:rootViewController];
[navigationController viewWillAppear:NO];
[aView addSubview:navigationController.view];
[navigationController viewDidAppear:NO];
At least this is what I found during development. I searched for this for a long time, and I still do not understand the reasons for this.
source
share