How can I know the orientation changed in AppDelegate

我们两清 提交于 2019-12-01 21:29:53

You can register for notifications when rotation occurs

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(handleDidChangeStatusBarOrientationNotification:) 
                                             name:UIApplicationDidChangeStatusBarOrientationNotification 
                                           object:nil];

Then implement the method that gets called when the message is sent

- (void)handleDidChangeStatusBarOrientationNotification:(NSNotification *)notification;
{
  // Do something interesting
  NSLog(@"The orientation is %@", [notification.userInfo objectForKey: UIApplicationStatusBarOrientationUserInfoKey]);
}

Alternatively check out the docs for UIApplicationDidChangeStatusBarOrientationNotification which will provide you with the

If you are talking about the interface orientation you could observe theUIApplicationDidChangeStatusBarOrientationNotification and if you want to be notified when the device orientation changed you can observe UIDeviceOrientationDidChangeNotification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!