I am presenting modal using the following code :
AddName *add = [[AddName alloc] initWithNibName:@"AddName" bundle:nil]
add.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalView:add animated:YES];
And After my work I use following code to go back on my main view.
[self dismissModalViewControllerAnimated:YES];
So it use to call -viewWillAppear
by default.
My problem is that,
It was working fine with iOS4.3.
But Its not working with iOS5.
What should I do ? Or Is that any bug in iOS5?
-viewWillAppear
is only guaranteed to be called in places where the -viewWillDisappear
has also been called. For most modal windows on the iPad, this is not the case, since they don't obscure the entire page.
The solution to your problem will depend on what you need the -viewWillAppear
for, but in general, you're likely to need to make a call directly from the same place that you dismiss the modal view controller.
One common mechanism for this, especially in cases where you might use that same modal view somewhere else, is to give the modal view controller a delegate which is called when the view is about to disappear. This will give you a chance to take the responses from the modal window, or even just force a data reload in the delegate view.
Hope this helps.
iOS 5 definitely changed their calls to viewWillAppear
and viewWillDisappear
. For instance, subviews (View Controller's views
as subviews to be exact) in a UIScrollView
, viewWillDisappear
will get called when you push another view controller onto the stack. However, when the view controller is popped, viewWillAppear
does not get called. These methods were never called in iOS 4 on UIScrollView
subviews.
This is strange behavior to me. Couple that with the fact that regardless of what should happen, if you could rely on it happening in iOS 4, it should not be working differently in iOS 5. Most of the time, I have no idea in which particular instance each one is called, I usually trial and error it as I'm in the zone coding. If it works the way I like, I move on. Then iOS 5 comes in and throws a wrecking ball into everything.
I have also experienced when a UINavigationController's
view is a subview, and a ViewController
is pushed on the navigation controller stack, viewWillAppear
never gets called in iOS 4, but does get called in iOS 5. Go figure.
I had the same problem.
I found that viewWillAppear
isn't get called after dismissing modal but viewDidAppear
is. So just try viewDidAppear
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With