Question

I have a navigation controller which I push a further view controller into when needed. This pushed view controller has a function fired off every minute using performSelector:withObject:afterDelay.

All this works fine but I've noticed that the function is still firing off long after having tapped < Back out of the pushed view controller.

I can see why this is happening- I'm not telling the pushed view controller to cancelPreviousPerformRequestsWithTarget upon exit. But since viewDidUnload is no longer supported and dealloc similarly doesn't seem to be called when tapping < Back, can anyone suggest the best way to go about performing this at the correct time?

Était-ce utile?

La solution

Look at - (void)viewWillDisappear:

Autres conseils

You have at least two entry points:

  • viewWillDisappear:, invoked when the view is about to disappear
  • viewDidDisappear:, invoked when the view has disappeared
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top