6

I need to check if viewWillDisappear: is called because I am presenting another UIViewController as modal or not. Does anyone know if this is possible?

UPDATE

I want to know why it is being called. For example, if its being popped or if another viewcontroller is shown as modal. I need to differentiate the both.

Kapil Choubisa
  • 5,152
  • 9
  • 65
  • 100
AlexanderN
  • 2,610
  • 1
  • 26
  • 42
  • Put nslog in viewWillDisappear. Exactly what you trying to do? – Durgaprasad May 30 '13 at 12:05
  • NSlog(@"ViewwillDisapper"); on that method. – Shashi Sharma May 30 '13 at 12:08
  • 5
    I don't understand why this question is heavily downvoted. There are methods `isBeingDismissed` and `isMovingFromParentViewController` that are meant to be called from within `viewWillDisappear` to determine the reason for the appearence change, so testing for this situation seems a valid question to me. – Martin R May 30 '13 at 12:14
  • Probably you do not want to know, when it is called in general but in a specific situation? http://stackoverflow.com/questions/1816614/viewwilldisappear-determine-whether-view-controller-is-being-popped-or-is-showi could be helpful – Amin Negm-Awad May 30 '13 at 12:10

2 Answers2

4

This is only a partial answer to your question, but have a look at "Determining Why a View’s Appearance Changed" in the "View Controller Programming Guide for iOS".

For example, you can call [self isBeingDismissed] from within viewWillDisappear to determine if the view controller was just dismissed (e.g. popped from the navigation stack).

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
1

You can set a breakpoint in that method or do NSlog(@"ViewwillDisapper"); So, you can verify whether that method is calling or not.

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
iPhone developer.
  • 2,122
  • 1
  • 16
  • 17