맞춤형 iPhone 앱에서 세로 보기를 가로 보기로 회전하는 방법

StackOverflow https://stackoverflow.com/questions/974905

  •  13-09-2019
  •  | 
  •  

문제

하나의 그래프 보기와 그 안에 분할된 컨트롤이 포함된 보기 컨트롤러가 하나 있습니다.뷰를 수평으로 회전시키는 방법은 무엇입니까?또한 가로 방향으로 다른 뷰를 로드할 수도 있나요?

미리 사전, Mladen

도움이 되었습니까?

해결책

다음을 통해 방향 지원을 구현합니다.

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// Just delete the lines for the orientations you don't want to support
  if((toInterfaceOrientation == UIInterfaceOrientationPortrait) ||
     (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) ||
     (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)) ||
     (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))  {   
   return YES; 
   }
return NO;
}

그런 다음 회전할 때 새 ViewController를 로드하려면 다음을 수행하세요.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
  if((fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
     (fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
  {    
    // Load the view controller you want to display in portrait mode...
  }
}

CoverFlow 모드로 전환할 때 iPod 앱에서 볼 수 있는 것처럼 부드러운 전환을 원할 경우 애니메이션을 설정하여 새 보기의 알파 속성을 조작할 수도 있습니다.

부인 성명인터페이스 회전을 지원하는 기본 방법은 3.0에서 변경되었습니다.위의 방법은 여전히 ​​작동하지만 더 부드러운 애니메이션을 얻는 방법이 있습니다.하지만 우리는 여기서 그것에 대해 이야기해서는 안 됩니다.더.주.

또 다른 면책조항인터페이스 회전을 지원하는 기본 방법은 6.0에서 다시 변경됩니다.위의 방법은 여전히 ​​작동하지만 더 부드러운 애니메이션을 얻는 방법이 있습니다.

다른 팁

장치 로테이션의 경우 ViewController 에서이 메소드를 구현해야합니다.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top