Question

I have a viewController that includes a live camera feed. Like many app, in the viewWillAppear and viewWillDisappear methods, I both start and stop the camera.

Like many times and situations, it seems that the viewWillDisappear is always called and the willWillAppear is not called anymore (since iOS 4.0 I would say?)

Here's the thing : when this view is the selectedVC of my TabBar, and the user shows tha notification center by ragging al the way down, the viewWillDisappear is always called and stops the live feed. But when this view is dismissed, I never get a callback that the controller is live again.

Any tips? Thx ;)

Was it helpful?

Solution

Since iOS5 the calls to viewWillAppear and viewWillDisappear changed obviously. So regardless of what should happen, if you could rely on it happening in iOS4, it should not be working in another way under iOS5. That's quite strange to me, it became a trial and error thing!

-viewWillAppear is only guaranteed to be called in places where the -viewWillDisappear has also been called before - but for most of the modal views/windows this seems not to be the case! And that's maybe the issue with the notification center, it's maybe treated as a modal window or so!

So unfortunately i don't have any good tips for you!

you could maybe check if applicationDidBecomeActive is being called when the notification center is closed and hook up your logic through the app delegate somehow.

- (void)applicationDidBecomeActive:(UIApplication *)application

From the iOS App Programming Guide:

In iOS 5, notifications that display a banner do not deactivate your app in the way that alert-based notifications do. Instead, the banner is laid along the top edge of your app window and your app continues receive touch events as before. However, if the user pulls down the banner to reveal the notification center, your app moves to the inactive state just as if an alert-based interruption had occurred. Your app remains in the inactive state until the user dismisses the notification center or launches another app. At this point, your app moves to the appropriate active or background state. The user can use the Settings app to configure which notifications display a banner and which display an alert.

OTHER TIPS

I just found a workaround using the AppDelegate ApplicationDidBecomeActive method. After that, I manually called the [selectedViewController viewWillAppear:YES]; :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top