2014-09-30 2 views
4

제 작업 응용 프로그램 (iOS 7.0.1)에서 UIDeviceOrientationDidChangeNotification이 호출되었습니다.iOS8 + UIDeviceOrientationDidChangeNotification이 호출되지 않음

이제 iOS 8.0에서이 응용 프로그램을 실행할 때 UIDeviceOrientationDidChangeNotification이 호출되지 않습니다.

많은 행운을 보았습니다.

편집-1 :

나는 방향 변경에 대한 관찰자를 추가하는 코드를 다음을 사용할 수 있습니다. 나는이를 만들었던 것을 발견 검색을 많이 후, 아이폰 OS 7 아이폰 OS 8. 없음 운

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; 
+0

이전 코드에서 변경하지 않고 iOS 8.0에서 작동합니다. 옵저버를 추가하고 곧 – iGW

+0

@iGW 나는 똑같이했다. – Kampai

+0

내 코드를 게시했습니다. 한번 봐주세요. iOS 8.0에서 작동합니다. – iGW

답변

3
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(didRotateDeviceChangeNotification:) 
               name:UIDeviceOrientationDidChangeNotification 
               object:nil]; 

내 경우>

-(void)didRotateDeviceChangeNotification:(NSNotification *)notification 
{ 
    UIInterfaceOrientation newOrientation = [UIApplication sharedApplication].statusBarOrientation; 
    if ((newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight)) 
    { 

    } 
} 
+0

이 회전 메소드는 iOS 8.0에서 사용되지 않습니다. Checked 'UIViewController.h' 클래스입니다. – Kampai

+0

@ Kampai, 나는 장치 방향 알림이 아직 사용되지 않을 것이라고 생각하지 않습니다. –

8

에서 완벽하게 작동 바보 같은 실수, 내 장치 potrait 방향 잠금 장치가 켜져 있습니다.

설정에서 기기 방향 잠금을 확인하십시오.

누군가에게 도움이 될 수 있습니다.

+0

같은 핀치 !!! :) –

1

스위프트 3 :

 NotificationCenter.default.addObserver(self, selector: #selector(orientationChanged), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) 

선택기 방법의 viewDidLoad에 UIDeviceOrientationDidChange에 옵저버를 추가는 다음과 같이이다 :

func orientationChanged(notification: Notification) { 

    } 

deinit 방법에 관찰자를 제거 추가하는 것을 잊지 마십시오

NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)