빈 응용 프로그램이 있고 스토리 보드 나 xib가 없습니다. 숨겨진 상태 표시 줄과 가로 방향 만 지원하고 싶습니다. 다시 말하지만, 코드 내에서만 변경 작업을 수행하지 않고 Info.plist를 건드리지 마십시오. 가로 방향을 사용할 때 UIWindow 크기가 잘못되었습니다.
문제는 내가 유일하게 지원되는 방향 풍경이다라는 컨트롤러와의 UIWindow를 생성합니다. 이 경우 내 UIWindow는 세로 모드의 차원에서 만들어지고 회전하지 않습니다. 예상되는 결과는 완전히 시안 색 인 화면입니다. 이것은 내 컨트롤러
#import "AppDelegate.h"
#import "AppViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor cyanColor];
self.window.rootViewController = [[AppViewController alloc] init];
[self.window makeKeyAndVisible];
return YES;
}
@end
:
이
내 대표입니다#import "AppViewController.h"
@implementation AppViewController
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
@end
나는 그렇게 해봤 무엇 제가 후 rootViewController를 설정하면
makeKeyAndVisible을 호출하면 처음에는 모든 것이 작동하는 것 같습니다.
self.window.backgroundColor = [UIColor cyanColor];
[self.window makeKeyAndVisible];
self.window.rootViewController = [[AppViewController alloc] init];
아직 몇 가지 문제가 있습니다. 우선 매우 취약한 것 같아서 나는 이것을 좋아하지 않습니다.
그것은 상태 표시 줄이 아닌 보이는 같은 : 두 번째 문제는 다음과 같은 결과를 얻을 rootViewController로 GLKViewController을 설정하는 더 복잡한 응용 프로그램 (예상 왼쪽에는 검은 색 영역 없을 것)이다 일찌감치 숨겨져 있습니다. , _UIApplicationHandleEventFromQueueEvent 예상치 못한 닐 창 몇몇 제스처 인식기 활성 및 GLKViewController에 흑색 영역을 클릭하면 다음 로그 메시지 산출 :
2014년 9월 25일 13 : 20 : 42.170 StackOverflowExample [107,907 6971]를 _windowServerHitTestWindow : UIClassicWindow : 0x7fa20b805e00; frame = (0 0; 375 667); userInteractionEnabled = NO; 제스처 인식기 = NSArray : 0x7fa20b80a620; layer = UIWindowLayer : 0x7fa20b806890
또한 빈 UIViewController를 첨부하고 내보기를 하위보기로 추가하는 등 다양한 다른 변경 작업을 수행했습니다. 이 경우 내보기가 올바르지 만 창은 여전히 잘못된 치수를 사용하고 있습니다.
내 View Controller의 supportedInterfaceOrientations 메소드를 재정의하지 않으면 모든 것이 올바르게 회전합니다. 그러나 그것은 물론 내가 원하는 것이 아닙니다.
만이 문제를 자신했다 Info.plist 파일에 추가 속성을 추가 할 수있는 시작 화면을 추가 할 때 문제가 해결
공유해 주셔서 감사합니다. 방금하는 방법을 알아 내려고 많은 시간을 보냈습니다. –
iOS8.1에서는 Swift를 사용하여 UIWindow의 너비와 높이에 작은 부분을 추가하여 여기에서 설명한대로 내 문제를 해결해야했습니다. http://stackoverflow.com/a/26452679/190599 – CodeReaper
대단히 감사합니다. 제비. –