Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewDidAppear called twice during state restoration #261

Closed
AndriyGo opened this issue Jun 2, 2014 · 9 comments
Closed

viewDidAppear called twice during state restoration #261

AndriyGo opened this issue Jun 2, 2014 · 9 comments

Comments

@AndriyGo
Copy link

AndriyGo commented Jun 2, 2014

In the center view controller (and, probably, others as well) viewDidAppear method is called twice when restoring state.

  1. The first call is triggered by

[self.centerViewController beginAppearanceTransition:YES animated:NO];
[self.centerViewController endAppearanceTransition];

in the (setCenterViewController: animated:) method of MMDrawerController.

  1. Second time it is called from viewWillAppear/viewDidAppear methods of MMDrawerController due to

a) [self.centerViewController beginAppearanceTransition:YES animated:animated]; in viewWillAppear
b) [self.centerViewController endAppearanceTransition]; in viewDidAppear

If the state is not getting restored, centre view controller's viewDidAppear is not called due to (1) and is only called due to (2).

I have tested and this is also the case with KitchenSink. I'd be happy to find a solution for this and issue a pull request, but I am stuck trying to understand why (1) calls viewDidAppear ONLY when restoring state.

@ronak2121
Copy link

+1 This has been a major pain for our app to the point of us dumping MMDrawerController and writing our own Left Nav Controller. Would really like not to have to do that; but the powers that be are forcing our hand.

Any help on this would be appreciated.

@pronebird
Copy link
Contributor

A sporadic idea: maybe we should check self.view.window to see if drawer is off-screen (not displayed yet) and ignore those appearance events, and drawer will have a chance to forward appearance events on viewWillAppear:.

@AndriyGo
Copy link
Author

AndriyGo commented Jul 4, 2014

Both #271 and #268 fix this issue. If I was to choose which one is better, I would choose #271 as it does not introduce another property and is thus a bit more elegant. It also fixes the double decodeObject call and potential reassignment of the same side controllers. Hope it will find its way into the next release

@ronak2121
Copy link

Is there any hope these fixes will actually get merged in?

@x2on
Copy link

x2on commented Jul 28, 2014

👍 please merge it!

@jerydarkside
Copy link

👍 I have this problem too and it is pretty annoying.

@kcharwood
Copy link
Contributor

Sorry for being MIA...

Work and Life get in the way of fun side projects :)

I'll try and pull together another release here in the next week.

🍻

@kcharwood
Copy link
Contributor

Closing. Take conversation to #271

@gotitplatform
Copy link

I have a MMDrawerController that is pushed onto a UINavigationController stack not animated and I get multiple calls to viewWillAppear and viewDidAppear

UPDATE:
I think I found the issue. I had a UINavigationController displayed behind a modal UIViewController. I was calling push (not animated) after I made an animated call to dismiss the modal. Moving the push (not animated) before calling dismiss (animated) on the modal achieved the results I was looking for and makes sense as to what was happening.

TLDR: Nevermind...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants