2011-03-14 2 views
1

UIViewController 기기 방향에 따라 레이아웃을 다시 적용하겠다는 알림을 보내려고합니다. 이렇게하려면 기본 센터에 UIDeviceOrientationDidChangeNotification을 게시하고 있습니다. 작동했지만 회전 애니메이션이 적용되지 않았습니다. 내가 잃어버린 것이 있다고 생각합니다. UIDeviceOrientationDidChangeNotification을 올바르게 게시하려면 어떻게해야합니까?`UIDeviceOrientationDidChangeNotification`을 올바르게 게시하는 방법은 무엇입니까?

답변

0

게시하려고 할 때 아무 것도 없어야한다고 생각하지 않습니다. 방향 변경이있을 때 자동으로 게시됩니다. 모자 사용을 원하면 옵서버를 추가해야합니다.

+0

UI의 방향 변경을 시뮬레이션하려고합니다. – Eonil

1

사용 :

[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:YES]; 

대신 당신이 게시 시스템 알림 안로서, (필요에 따라 LandscapeRight 교체).

- (void)updateOrientation 
{ 
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; 
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
} 

을하지만, 물론, 당신은 더 단정해야하고 회전을 중지해야 할 때 [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]를 호출하고 당신이 그것을 처리 할 준비가되면 당신은 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 전화 :

1

그것은 당신을 위해 이벤트를 게시 할 예정입니다 다시 : 그것은 귀하의보기 컨트롤러에 필요한 모든 콜백을 호출합니다.

관련 문제