How do you define your views for AViewController and BViewController ? Usually you use initWithNibName , for example.
AViewController *aObj = [[AViewController alloc] initWithNibName:@"mynibname" bundle:nil]`
As Carl noted, you can only use init (although I donβt see this class documented in the UIViewController Reference class ), but then the system will be very specific with respect to the name of your NIB file. The documentation does say that you can use initWithNibName and pass nil for the NIB name, in which case it will try to find it for you. Personally, if you have inconsistent results, I will try to use initWithNibName and explicitly pass the name of your NIB and see if this fixes the situation.
Or do you create your view programmatically using loadView in two controllers? Then you need to show us those loadView procedures (not to be confused with viewDidLoad ).
But according to the documentation, you need to either specify your NIB or use loadView . See Discussion Viewing Management in the UIViewController Link to a Class.
Update:
Given your feedback, I have a few thoughts:
Needless to say, the problem is apparently not related to the code above. You need to expand your search and show us more code. Perhaps show us your viewDidLoad from B?
Usually, when you do not receive such events, this is due to the fact that the hierarchy of the view manager is not synchronized with the hierarchy of the view. The most common way people do this is to do something like β [addSubview someNewController.view] β at some point. If you use the view controller in any context than (a) the initial configuration of the application delegate; (b) presentViewController (or termination); or (c) pushViewController (or pop), then you can share what you have done.
As andreamazz noted, your comment: βMy navigation controller is inside the tab view controller's view controller,β is a little worrying if you read it literally. You can put the navigation bar in the view controller view, but you cannot put the navigation controller in the view controller (unless you close the controller controller, which is a completely different beast). Similarly, in another question, you said: "Embedding a UINavigationController or UITabBarController (my case) in the UIViewController somehow interrupts the call to these methods." The fact is that you do not embed navigation controllers in other view controllers (if it is not itself, a container controller, such as a tab view controller), but vice versa. But if you literally mean that you have a controller that contains a navigation controller, you must show us how you do it (the correct containment of the controller?), Because it is very unusual.
This is unusual, but I had projects that were damaged, ending up in strange conditions. At a minimum, I can offer a βProductβ - βCleanβ and rebuild. If the problem persists and you have identified the problem for the B NIB, then temporarily rename it and create a quick and dirty one from scratch.
source share