ios - UIDeviceOrientation 通知

标签 ios objective-c uideviceorientation

为了接收 UIDeviceOrientation 更改通知,必须做两件事:

  1. UIDevice 上调用 beginGeneratingDeviceOrientationNotifications
  2. 注册接收通知。

这是我的问题:

假设我有两个 View Controller 想要接收这些通知,第一个调用 beginGeneratingDeviceOrientationNotifications 并注册,然后第二个执行相同的操作。现在我的第一个 VC 卸载和注销并调用 endGeneratingDeviceOrientationNotifications。即使第一个 VC“关闭它们”,第二个 VC 是否会继续接收这些通知?

最佳答案

是的。 begin… 方法的文档至少是这样说的:

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

这种接口(interface)通常使用一些计数器来实现。每个 begin... 方法递增计数器,每个 end... 方法递减它。只要计数器大于零,就会发送通知。

关于ios - UIDeviceOrientation 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14241616/

相关文章:

ios - 核心剧情:reloading/refreshing 3 pie plots in core plot

ios - 单击电源按钮的系统通知或任何委托(delegate)方法 - iOS

ios - AVCaptureSession如何使静音输入音频设备?

ios - UIDeviceOrientationDidChangeNotification 返回错误的方向

objective-c - 与方向更改有关的EXC_BAD_ACCESS/KERN_INVALID_ADDRESS

iphone - CGAffineRotation 倾斜图像照片

iphone - 后台模式下的音频切换 AVFoundation - Objective-c

ios - 警告 : Could not load any Objective-C class information using PaintCode's code

ios - 如何同时显示聊天 UI 的文本和按钮

objective-c - 动画自定义 NSView 绘图