iOS 외부 디스플레이 프로그래밍 방식으로 표시됩니다
-
13-12-2019 - |
문제
모든 .xib 파일을 사용하지 않고 iOS 앱에서 외부 디스플레이를 지원하려고합니다.
바로 지금 내 코드에는 다음이 포함됩니다.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
if ([[UIScreen screens] count] > 1){
externalScreen = [[UIScreen screens] objectAtIndex:1];
UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:0];
externalScreen.currentMode = current;
externalWindow = [[UIWindow alloc] initWithFrame:[externalScreen bounds]];
externalWindow.screen = externalScreen;
externalWindow.clipsToBounds = YES;
extController = [[ExternalController alloc] init];
[externalWindow addSubview:extController.view];
[externalWindow makeKeyAndVisible];
}
self.window = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:0] bounds]];
mainController = [[ViewController alloc] init];
[self.window addSubview:mainController.view];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
}
.
이 작업을 실행하면 TV OUT 화면이 즉시 닫힙니다. 내가이 줄을 댓글을 달리면
//self.window = [[UIWindow alloc] initWithFrame:[[[UIScreen screens] objectAtIndex:0] bounds]];
.
TV 출력 화면이 제대로 작동하지만, 물론 내 시뮬레이터 화면에 아무 것도 보이지 않습니다.
누구도 내가해야 할 일이 있습니까?미리 감사드립니다!
해결책
GitHub에서 샘플 소스 코드 TVout을 시도하는 것을 제안 할 수 있습니다 - https://github.com/johngoodstadt/tvout.
그것은 비슷한 코드를 당신과 함께 사용하지만 당신이 자신의 코드에서 복사하고 통화 할 수있는 클래스에 패키지화되어 있습니다.
디스플레이 문제를 해결해야합니다.그런데 'didfinishlaunchingwithoptions'에서와 같이 코드를 'DidfinishlaunchingWithOptions'에서 일찍이하지 않을 것입니다.
제휴하지 않습니다 StackOverflow