質問

In order to receive UIDeviceOrientation change notifications, one must do two things:

  1. call beginGeneratingDeviceOrientationNotifications on UIDevice
  2. register for the notifications.

Here's my question:

Let's say I have two view controllers who want to receive these notifications and the first calls beginGeneratingDeviceOrientationNotifications and registers, then the second does the same. Now my first VC unloads and unregisters and calls endGeneratingDeviceOrientationNotifications. Will the second VC continue to receive these notifications even though the first VC "turned them off"?

役に立ちましたか?

解決

Yes. The documentation for the begin… method says so, at least sort-of:

You may nest calls to this method safely, but you should always match each call with a corresponding call to the endGeneratingDeviceOrientationNotifications method.

This kind of interface is usually implemented using some counter. Each begin… method increments the counter, each end… method decrements it. The notifications are sent as long as the counter is greater than zero.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top