2011-02-17 6 views

답변

3
  • 반환 :

[[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(didRotate:) 
               name:UIDeviceOrientationDidChangeNotification 
               object:nil]; 
  • 와 당신이 원하는 바로보기 회전 : 나는 CGAffineTransformMakeRotation()를 사용하려고

self.theView.transform = CGAffineTransformIdentity; 
self.theView.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); 
+0

을하고 그것을 잘 일하고있어. 회전 알림을 처리하는 방법을 잘 모르겠지만이 메서드를 사용하면 요소에 순환 효과를 유지할 수 없습니다. –

+0

한 가지만 회전시키기를 원하므로 "시스템"에보기 컨트롤러가 회전하지 않도록 지시해야합니다. 그렇지 않으면 모든 요소가 회전하게됩니다. 즉 "아니오"가 반환됩니다. 그렇다면 장치가 언제 회전하는지 어떻게 알 수 있습니까? 그것이 통보를 처리하는 것이며, 회전 할시기를 알려줍니다. – Bogatyr

+0

좋아, 이해했다. 그러나 언제 통보해야합니까? 장치가 회전하면 오른쪽으로. 그러나 장치의 회전을 어떻게 감지합니까? 감사. –

1
UIView *localView = [mainView viewWithTag:tagOfScrollViewToRotate]; 
UIInterfaceOrientation deviceOrientation = [UIApplicationsharedApplication].statusBarOrientation; 

      float angle; 
      switch (deviceOrientation) { 
       case UIInterfaceOrientationPortraitUpsideDown: 
       { 
        angle = M_PI; 
        CGAffineTransform transform = CGAffineTransformMakeRotation(angle); 
        [localView setTransform:transform]; 

        break; 
       } 
       case UIInterfaceOrientationLandscapeLeft: 
       { 
        angle = -M_PI/2; 
        CGAffineTransform transform = CGAffineTransformMakeRotation(angle); 
        [localView setTransform:transform]; 
        localView.frame = CGRectMake(0, 0, 768, 1024); 

        break; 
       } 
       case UIInterfaceOrientationLandscapeRight: 
       { 
        angle = M_PI/2; 
        CGAffineTransform transform = CGAffineTransformMakeRotation(angle); 
        [localView setTransform:transform]; 
        localView.frame = CGRectMake(0, 0, 768, 1024); 
        break; 
       } 

       default: 
       { 
        angle = 0; 
        break; 
       } 
      } 

행운을 빌어 요, : D NO에서

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
  • 장치 회전 통지를 직접 처리

관련 문제