iOS 6에서 자동 노력을 위해 앱을 완전히 올바르게 작동시키는 방법은 무엇입니까?
-
11-12-2019 - |
문제
iOS6에서 shouldAutorotateToInterfaceOrientation
는 더 이상 사용되지 않습니다.supportedInterfaceOrientations
및 shouldAutorotate
를 사용하여 Autotation에 대해 앱을 올바르게 작동시키지 만 실패했습니다.
이 ViewController는 회전하고 싶지는 않지만 작동하지 않습니다.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
.
아이디어가 있습니까? 사전에 도움을 주셔서 감사합니다!
해결책
그것을 알아 냈습니다.
1) 하위 클래스 된 UINAvigationController (계층 구조의 상위 ViewController가 방향을 제어 할 수 있습니다.)
그것을 self.window.rootViewController로 설정했습니다.
.
- (BOOL)shouldAutorotate
{
return self.topViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self.topViewController.supportedInterfaceOrientations;
}
2) 뷰 컨트롤러를 원하지 않는 경우
.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
3) 로 회전 할 수있게하려면
.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
-(BOOL)shouldAutorotate
{
return YES;
}
btw, 필요에 따라 다른 관련 방법 :
.- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
다른 팁
루트 컨트롤러로 탐색 컨트롤러 대신 탭 막대 컨트롤러를 사용하는 경우 uitabbarcontroller를 유사하게 사용해야합니다.
구문이 다릅니다.나는 성공으로 다음을 사용했다.그런 다음 위의 예제를 사용하여 재정의하려는 관점 컨트롤러에서 성공했습니다.내 경우에 나는 주 화면이 회전하지 않기를 바랬지 만 자연스럽게 가로보기를 사용하기를 원한 영화가있는 FAQ 화면을 가졌습니다.완벽하게 일했다!Self.ModalViewController에 구문 변경 사항을 기록하십시오 (탐색 컨트롤러에 대한 구문을 사용하려고하면 컴파일러 경고가 나타납니다.) 희망이 도움이됩니다!
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotate
{
return self.modalViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self.modalViewController.supportedInterfaceOrientations;
}
.