Kam*_*pai 4 nsnotificationcenter uiinterfaceorientation ios swift
在我的工作应用程序(iOS 7.0.1)中,UIDeviceOrientationDidChangeNotification被调用.
现在,当我在iOS 8.0中运行此应用程序时,UIDeviceOrientationDidChangeNotification没有被调用.
尝试了很多,但没有运气.
编辑-1:
我使用下面的代码添加观察者的方向更改.适用于iOS 7,完美适用于iOS 8.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotateDeviceChangeNotification:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
>
-(void)didRotateDeviceChangeNotification:(NSNotification *)notification
{
UIInterfaceOrientation newOrientation = [UIApplication sharedApplication].statusBarOrientation;
if ((newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight))
{
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8665 次 |
| 最近记录: |