4
votes

I am approaching mental trying to solve this issue:

The situation:

I have a pretty basic application, an an MMDrawerController with a tableview inside, which links to a uitabbarcontroller when an item is pressed. Inside the first page of that is an embedded youtube UIWebView which when pressed played a youtube video fullscreen.

Here is what is happening.

  1. Press video, opens in fullscreen and starts playing
  2. UITabBar viewWillDisappear fires
  3. Root MMDrawerController viewWillAppear fires
  4. Video Ends
  5. User back to UITabBar they started and everything seems fine even though it 'disappeared' earlier

Now I put booleans in the ViewWillAppears / Disappears of the two views to check what the current state of the app is like. Usually it's 0,1 indicating either the table is open or the uitabbarcontroller is open. After the video, they show 0,0. If I press back on the navigation I get "Unbalanced calls to begin/end appearance transitions" when navigating from wherever I am.

Right now If I listen for the start of the youtube video and then fire:

[self.navigationController popToRootViewControllerAnimated:NO];

I can prevent the unbalanced calls, from occurring and the user can continue to navigate the app. However they don't get to watch the video and they just get thrown back a view.

As well in 3. I can check for 0, 0 on the two controllers and then pretty much reboot the whole app. But thats not a good solution.

Intended outcome:

The user can press the uiwebview, watch the video, and afterwards they are returned to where they left off. If they hit back on the navigation controller, no unbalanced appearance transitions.


I've tried a bunch of stuff, like

[self.navigationController poptoViewController:...]


From what I gather at this point, it has something to do with fullscreen videos loading in the root controller (hence its viewWillAppear firing at 3.) but I'm not getting 'placed' back correctly afterwards. Something like

[self.navigationController heyTheUserIsPresentlyIn:self]

That I can call after the video goes away would be crazy good.

Any assistance is much appreciated, although I've been on this for hours and hours, If I'm a moron any links to docs or sections in books would help a lot. Thanks.

2

2 Answers

3
votes

It sounds like ViewController life-cycle issue.

Are you sure you want to navigate from a UITableView to a UITabBarController? Try remove the latter because it's normally the root ViewController and calls to viewWillDisappear and viewWillAppear could be made based on this assumption.

If you need a tabbed like control which is not the root ViewController maybe consider rolling your own?

1
votes

Well this happens when a sequence of navigation animation or animation started without
properly ending first animation, so i can guess the same is with your animation, take care
of your animation even if it is not due to Navigation controller.
Hope it helps you