2012-03-15 2 views
2

PhoneGap ExternalScreen 플러그인을 사용하고 있지만 여러 해상도를 지원할 수 있도록 약간 수정했습니다. 해상도는iOS Second Screen

- (void) toggleResolution:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options 
{ 
    self.callbackID = [arguments pop]; 
    if ([[UIScreen screens] count] > 1){ 
     externalScreen = [[[UIScreen screens] objectAtIndex:1] retain]; 
     screenModes = [externalScreen.availableModes retain]; 
     UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"External Display Size" 
                message:@"Choose a size for the external display." 
                delegate:self 
                cancelButtonTitle:nil 
                otherButtonTitles:nil] autorelease]; 

     for (UIScreenMode *mode in screenModes){ 
      CGSize modeScreenSize = mode.size; 
      [alert addButtonWithTitle:[NSString stringWithFormat:@"%.0f x %.0f pixels", modeScreenSize.width, modeScreenSize.height]]; 
     } 
     [alert show]; 
    } else { 
     PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_ERROR messageAsString:WEBVIEW_UNAVAILABLE]; 
     [self writeJavascript: [pluginResult toErrorCallbackString:self.callbackID]]; 
    }  
} 



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    UIScreenMode *desiredMode = [screenModes objectAtIndex:buttonIndex]; 
    externalScreen.currentMode = desiredMode; 
    externalWindow.screen = externalScreen;  
    [screenModes release]; 

    CGRect rect = CGRectZero; 
    rect.size = desiredMode.size; 
    externalWindow.frame = rect; 
    externalWindow.clipsToBounds = YES; 

    externalWindow.hidden = NO; 
    [externalWindow makeKeyAndVisible]; 

    PluginResult* pluginResult = [PluginResult resultWithStatus:PGCommandStatus_OK messageAsString:WEBVIEW_OK]; 
    [self writeJavascript: [pluginResult toSuccessCallbackString:self.callbackID]]; 
} 

: 여기처럼 내 코드는 모습입니다 iPadVGAOutput (http://mattgemmell.com/2010/06/01/ipad-vga-output/)에 매트 Gemmel의 포스트에서 몇 가지 팁을 얻었다 잘 바뀌지 만 콘텐츠가 올바른 크기로 제한되지 않습니다. 다음 예는 다음과 같습니다

를 두 번째 화면은 원래 (1920 × 1080에서)로드되면, 그것은 다음과 같습니다 http://cl.ly/F41K

I : http://cl.ly/F5IV

1280 * 720으로 해상도를 변경 한 후에는 다음과 같습니다 상대적으로 Objective-C에 익숙하지 않지만 신속하게 가져옵니다. 내 문제를 해결하고 코드를 개선하는 데 도움이 될만한 지침이 될 것입니다. 감사!

앤드류

편집 : 나는 또한 내가 수동으로 표시되어있는보기 및/또는 CSS의에 어떤 너비/높이를 설정하고 있지 않다, 명확하고 싶었다.

+0

보조 화면을 사용해야합니까? iOS 미러링으로 도망 갈 수 있습니까? 나는 미러링이 두 번째 스크린에 비해 전반적으로 훨씬 나은 경험을 제공한다는 것을 발견했다. 요구 사항을 충족시키지 못할 수도 있지만 평가할 가치가 있습니다. – Alan

+0

Alan, 불행히도 우리는 두 번째 화면이 16 : 9 비율이고 iPad가 4 : 3이므로 두 번째 화면을 사용해야합니다. 기본적으로 미러링되지만, 두 번째 화면 코드를 수동으로 작성하지 않고 검은 색 막대를 제거하는 방법을 알지 못한다면 우리는 붙어 있습니다! : – andrewpthorp

+0

아프 ipad ... 쓰레기. 풍경에서 아이폰 4와 꽤 잘 작동합니다. 난 그냥 30 "디스플레이에 우리의 ipad 애플 리케이션을 확인, 그리고 그것은 검은 막대가있다. – Alan

답변

1

아무도 찾지 못했기 때문에 Objective-C를 파헤 치고 해결했습니다. 나는하여 alertView 방법에 다음을 추가했다 :

webView.frame = rect; 
1

솔루션은 나를 위해 작동하지 않았다로서 내가 여기에 내 솔루션을 넣을 수 있습니다. 화면 크기가 올바르게 감지되었지만보기 주위에 검정색 막대가 나타납니다. 방금 설정해야만했습니다

[externScreen setOverscanCompensation: UIScreenOverscanCompensationInsetApplicationFrame]; 

그리고 막대가 사라졌습니다.