Question

I'm new to iOS programming and I'm spending way too much time on something that is supposed to be relatively easy to implement. Surely this is a beginner's question, but I just can't seem to find an answer.

I'm currently developing an iOS VoIP app. At this stage the system will switch to a "CallingViewController" whenever a call is set up. Whenever the call is disconnected the view should disappear (pop).

My hierarchy:

  • Window
    • navigationController : UINavigationController (window.rootViewController)
      • AppController : UIViewController (navigationController.rootView)
        • TabBarController : UITabBarController
          • DialerViewController : UIViewController
        • LoginViewController : UIViewController
        • CallingViewController : UIViewController

I imagined AppController to be the class which loads and hides views based on states and events being triggered by all the VoIP related coding.

For instance in the AppController I use [self.navigationController pushViewController:tabBarController animated:YES]; . Pushing a controller does not seem to cause any problems, everything functions as expected.

Pushing tabBarController causes DialerView to get focus (it is for now the only view in te tab, later it will for instance contain: Dialer, Settings, Contacts, Call History). The user enters a number and presses "VoIP Call". Via callbacks (voiplibrary->OnCallStateChange -> eventually AppController.OnCallStateChange) the system can determine the state of Call (callId) has changed to "SET UP" and will push (in AppController) [self.navigationController pushViewController:CallingViewController animated:YES]; .

Through the same callback function the system will also determine that the call had ended. Yet, using popViewController or any variant, it does not work. The ViewController stays on top. I started logging using NSLog and it appears the CallingView: loads, willappear, didappear and willdisappear. DidDisappear will not get called however. The system also did determine the call was terminated, checked via NSLog again. So whatever code I use to get rid of the CallingViewController will get executed (it seems), however the View does not change.

Was it helpful?

Solution

I can't say if that is the cause for your problem but as per documentation

for

pushViewController:animated:

method

This object cannot be an instance of tab bar controller and it must not already be on the navigation stack.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top