4

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.

Andrew Plummer
  • 1,150
  • 1
  • 12
  • 21

2 Answers2

3

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?

Diosney
  • 10,520
  • 15
  • 66
  • 111
1

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

umer sufyan
  • 1,005
  • 1
  • 12
  • 22
  • So this is problem is entirely because of animations screwing up? If i kill every transition animation in the app with that fix the problem? – Andrew Plummer Oct 25 '13 at 04:10
  • 1
    sure in my case i solved in the same manner, give it a try, and let me know then. and also take care of Navigation Controller animation if you presenting consecutive view controller animation before the first one animation end. – umer sufyan Oct 25 '13 at 04:11
  • Nope, this didn't do anything. Neither did implementing that combined with the delay solution here http://stackoverflow.com/questions/8563473/unbalanced-calls-to-begin-end-appearance-transitions-for-uitabbarcontroller To clarify, the app functions perfectly *until* I watch a fullscreen video from the UIWebView, then after that its broken. – Andrew Plummer Oct 25 '13 at 04:48
  • by all means it is animation problem, you have to tackle that in some proper way as i said start the next animation after the first one animation gets end. – umer sufyan Oct 25 '13 at 04:51
  • I understand what you are saying, however I have turned off the animation and this does not solve the issue. I am aware that this error can also occur from two view controllers being called at the same time, which may make sense considering viewWillDisappear is being called twice on the same view controller, without an intermediary viewWillAppear. However, this does not address the underlying issue, what is happening with this full screen video that changes everything from that point onwards in the app. – Andrew Plummer Oct 25 '13 at 05:18
  • please put you sequence of animation code to the full screen video code – umer sufyan Oct 25 '13 at 05:28