조경 모드에서 내비게이션 바 및 내비게이션 컨트롤러를 변환하는 방법

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

  •  03-07-2019
  •  | 
  •  

문제

조경 모드를 사용하는 게임을 개발 중입니다. 총 4 개의 뷰가 있습니다. 조경 모드에서 2 개의 뷰가 올바르게 나옵니다. 그러나 세 번째 관점에서 나는 uability and navigation bar를 가지고 있습니다. 조경 모드에서 테이블을 회전시킬 수 있지만 탐색 표시 줄과 내비게이션 컨트롤러를 변환 할 수는 없습니다. 내비게이션 바 및 내비게이션 컨트롤러에도 버튼이 있습니다. 또한 변형되지 않습니다. 누구나 이것에 대한 해결책을 가질 수 있습니다. :)

도움이 되었습니까?

해결책

Transform the nagvigation controller's navigation bar by rotaiong it with 90 degree. Also you might require to set the navigation bar center and frame for setting the proper width to fit with landscape mode..it worked for me :) hope it helps you too.

다른 팁

#define degreesToRadians(x) (M_PI * x / 180.0)

- (void)viewWillAppear:(BOOL)animated
{

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];

    CGRect newBounds = CGRectMake(0, 0, 480, 320);
    self.navigationController.view.bounds = newBounds;
    self.navigationController.view.center = CGPointMake(newBounds.size.height / 2.0, newBounds.size.width / 2.0);

    self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90));

    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.view.transform = CGAffineTransformIdentity;
    self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
    self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 320.0, 480.0);

    [super viewWillDisappear:animated];
}

In UIViewController documentation's Class:

Handling Rotations

interfaceOrientation property
– shouldAutorotateToInterfaceOrientation:
– rotatingFooterView
– rotatingHeaderView
– willRotateToInterfaceOrientation:duration:
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:

hope this helps you too.

A.

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