2009-09-01 9 views

답변

17

UIDeviceOrientationDidChangeNotification을 준수하십시오

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

... 

- (void)orientationDidChange:(NSNotification *)note 
{ 
    NSLog(@"new orientation = %d", [[UIDevice currentDevice] orientation]); 
} 

UIDevice Class Reference

난 당신이 이러한 알림이 전송하고자 할 때 요 유니드가 -beginGeneratingDeviceOrientationNotifications을 추가 할 수 있습니다, 당신이 그들을 중지 할 때 -endGeneratingDeviceOrientationNotifications를 호출해야합니다. 배터리를 생성 할 때 배터리에 영향을 미치므로보기가 화면에 나타나면 그렇게해야합니다. UIViewController이 모든 작업을 수행하므로보기 컨트롤러가있는 경우 작업을 수행 할 가치가 있습니다.

2
당신은 전체 알림에 가입하고 장치가 회전 할 때 전화를받을 수

, 그것은 실 거예요 ...하지만 당신을 위해 아무것도 할

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

방금 ​​새 크기/레이아웃 경우에 뷰를 조정하려면 오리엔테이션이 변경되면 layoutSubviews 메소드를 재정의해야합니다.

일반적으로보기를 회전 할 때 발생하는보기의 크기가 변경 될 때마다 호출됩니다.

+0

layoutSubviews 호출의 변경 사항을 애니메이션화 할 수있는 완벽한 솔루션입니다. –

관련 문제