iOS 5 : -viewWillAppear is not called after dismissing the modal in iPad

后端 未结 3 2123
借酒劲吻你
借酒劲吻你 2020-12-15 04:28

I am presenting modal using the following code :

AddName *add = [[AddName alloc] initWithNibName:@\"AddName\" bundle:nil]
add.modalPresentationStyle = UIMod         


        
相关标签:
3条回答
  • 2020-12-15 04:44

    I had the same problem. I found that viewWillAppear isn't get called after dismissing modal but viewDidAppear is. So just try viewDidAppear instead.

    0 讨论(0)
  • 2020-12-15 04:47

    -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.

    0 讨论(0)
  • 2020-12-15 04:56

    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.

    0 讨论(0)
提交回复
热议问题