Hy, 이 주제가 이전에 요청되었지만 모든 솔루션을 검토했지만 아무도 내가 해결하지 못했습니다.가로로 시작한 후보기가 세로로 시작되도록 설정할 수 없습니다.
내 앱은 모두 세로 형식이며 가로보기 형식의보기 컨트롤러는 하나뿐입니다.
나는 관계없이 장치 방향 세로 방향 강제로 모든 뷰 컨트롤러에 다음 코드를 추가 : 장치가의 ViewController가 제대로 열립니다 세로 모드로 설정되어있는 경우- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate{
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
-(void)ViewDidLoad()
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
을하지만, 장치는 가로 모드로 설정되어있는 경우 앱을 열기 전에 가로로 스플래시 화면을 시작하고보기 컨트롤러의 일부를 잘라내어 가로로 표시 한 다음 세로보기 모드로 회전하고 그림과 같이 화면 일부를 잘린 상태로 유지합니다. 응용 프로그램의 위임에
는 :[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationPortrait;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
감사 :
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
그리고 AppDelegate에의
또한, 단지 탐색 컨트롤러에 뷰 컨트롤러를 추가하기 전에 나는 다음과 같은 추가 문제에 대한 조언을 구하십시오.불명확하거나 정보가 필요할 수있는 경우 문제를 분명히 알려 주시기 바랍니다.
확인이 https://stackoverflow.com/questions/47274111/force-landscape-when-orientation-is-locked/47274224#47274224 –
나는 이미 그것을 사용하고 있습니다 : [[UIDevice currentDevice]의 setValue : NSNumber numberWithInteger : UIDeviceOrientationPortrait] forKey : @ "orientation"]; – coder