1

내 응용 프로그램은 모든 방향을 지원하지만 경우에 따라iPhone에서 화면을 세로/가로로 고정하는 방법은 무엇입니까?

세로/가로 모드로 화면을 잠그고 자합니다.

내 응용 프로그램에는 두 종류의 pdf 문서가 있습니다.

하나는 세로 방향 문서에 있고 다른 하나는 가로 문서입니다.

는 난 단지 세로보기 세로 문서를 열려면, 그리고

가로보기 만의 풍경 문서.

내가 이렇게하고 싶지 :

내 응용 프로그램 경우는 풍경이 같은 세로보기로 회전과 동일해야한다, 그래서 내 응용 프로그램이 가로보기에서 열려 있고 내가

세로 문서를 클릭하면 세로보기로 열어 가로 문서를 클릭하면

이 회전해야하며 그렇지 않은 경우 가로로만 문서를 열어야합니다.

희망 난 당신이 내가

당신의 도움이 필요 기쁘게 원하는 것을 이해 너희들은 분명히 나의 영어 희망을 용서합니다.

여기 내 일부 코드 사전에 감사합니다

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 

    if (orientation == UIInterfaceOrientationPortrait || orientation == 
     UIInterfaceOrientationPortraitUpsideDown) { 

      NSLog(@"Portrait"); 
      if ([orientationObject isEqualToString:@"p"]) { 
       //If the document is portrait 
       pdfScrollViewFrame = CGRectMake(-0.0, -80.0, 770.0, 1085.0); 
      } 
      else{ 
       // If the document is landscape 
       pdfScrollViewFrame = CGRectMake(-0.0, -40.0, 770.0, 1130.0); 
      } 
     } 
     else{ 

      NSLog(@"Landscape"); 

      if ([orientationObject isEqualToString:@"p"]) { 
      //If the document is portrait 
       pdfScrollViewFrame = CGRectMake(65.0, -80.0, 620.0, 1110.0); 
      } 
      else{ 
       //if the document is landscape 
       pdfScrollViewFrame = CGRectMake(0.0, -40.0, 740.0, 1070.0); 
      } 
     } 
+0

이 http://stackoverflow.com/ 도움이 될 : 나는 다음을 수행 할, viewDidAppear 이후에만 잠금 회전하기 위해

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toOrientation duration:(NSTimeInterval)duration { if (toOrientation == UIInterfaceOrientationMaskLandscape) pdfScrollViewFrame.transform = CGAffineTransformMakeRotation(M_PI/2); … // handle all other cases here } 

:이 경우 같은 뭔가를 시도 할 수 있습니다 질문/15110838/xcode-how-do-i-keep-views-portrait-mode-but-still-allow-one-view로보기 – Kassem

+0

이것은'xcode '와 무슨 상관이 있습니까? – Popeye

답변

2

iOS6의 +를 들어, 당신은 당신의 컨트롤러에이를 추가 할 수 있습니다 :이 도움이

- (BOOL)shouldAutorotate { 
    YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 

    if (<PDF is portrait>) 
    return UIInterfaceOrientationMaskPortrait; 
    if (<PDF is landscape>) 
    return UIInterfaceOrientationMaskLandscape; 

    return UIInterfaceOrientationMaskAll; 

} 

희망을.

편집 :

난 당신이 수동으로 원하는 결과를 얻을 수있는 PDF를 회전해야하는 경우 확실하지 않다.

@interface… 
… 
    @property (nonatomic) BOOL isRotationLocked; 
… 
@end 

@implementation… 
… 
- (void)viewDidAppear:(BOOL)animated { 
    … 
    self.isRotationLocked = YES; 
} 

- (BOOL)shouldAutorotate { 
    YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 

    if (self.isRotationLocked) { 
    if (<PDF is portrait>) 
     return UIInterfaceOrientationMaskPortrait; 
    if (<PDF is landscape>) 
     return UIInterfaceOrientationMaskLandscape; 
    } 
    return UIInterfaceOrientationMaskAll; 

} 
… 
+0

그리고 난 내 응용 프로그램에서 가장 최근의 github UIPageViewController-PDF 프로젝트를 사용하고 있습니다. 프로젝트에서 나는 많은 시간 동안 오리 엔테이션을 처리하려고 노력하고 있습니다. 여러분에게 계속 묻고 있습니다. –

+0

제발 내 편집을 확인하고, 그것이 올바르게 이해되기를 바랍니다 ... – sergio

+0

내 응용 프로그램이 가로보기 (모드)로 열려 있고, 내 초상화 PDF 문서를 열 때 다음보기 (두 번째 화면)에서는 세로 모드로 화면을 회전시켜야합니다.내 응용 프로그램은 모든 방향을 지원하지만 여기서 문서를 여는 데는 문서가 세로인지 확인해야하므로 컨트롤러가 세로로 회전해야합니다. 또는 가로 문서를 클릭하고 세로 방향으로 응용 프로그램을 실행하면 가로 방향으로 방향이 바뀌어야합니다. 당신은 내가 무엇을 말하려고하는지 이해하고있다. ( –