2014-01-15 1 views
1

Google/Stackoverflow에서 이미 "모든 것"을 검색했습니다.하지만 여전히 문제가 있습니다. 나는 OSX Apps를 개발하기 시작 했으므로 Objective-C와 Xcode 5 (5.0.2)에서 (거의) 완전한 초보자이다.Mac WebView에서 손가락 집게 확대를 사용 설정하는 방법?

내가 필요한 것은 주어진 URL에서 웹 게임을로드하는 간단한 webview입니다. 이 웹뷰는 아주 간단한 사파리 브라우저처럼 행동해야합니다. 내 응용 프로그램은 이미 비교적 잘 작동하고 있습니다. 게임에 OK를로드하고 많은 고민 끝에 자바 스크립트 경고 및 확인을 표시하는 데 성공했습니다.

내 작업으로 핀치 줌이 작동합니다.

#import "AppDelegate.h" 

    @implementation AppDelegate 

    @synthesize myWebView; 

    // Enables confirms: 
    - (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { 
    NSInteger result = NSRunInformationalAlertPanel(NSLocalizedString(@"Confirmação", @""), // title 
    message,    // message 
    NSLocalizedString(@"OK", @""),  // default button 
    NSLocalizedString(@"Cancelar", @""), // alt button 
    nil); 

    return NSAlertDefaultReturn == result; 
    } 

    // Enables alerts: 
    - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { 
     NSAlert *alert = [[NSAlert alloc] init]; 
     [alert addButtonWithTitle:@"OK"]; 
     [alert setMessageText:message]; 
     [alert runModal]; 
     //[alert release]; 
    } 

    // This was supposed to enable pinch zoom: 
    - (void)magnifyWithEvent:(NSEvent *)event { 
     //[resultsField setStringValue: 
     //[NSString stringWithFormat:@"Magnification value is %f", [event magnification]]]; 
     NSSize newSize; 

     newSize.height = [[NSScreen mainScreen] frame].size.height * ([event magnification] + 1.0); 
     newSize.width = [[NSScreen mainScreen] frame].size.width * ([event magnification] + 1.0); 

     //[self setFrameSize:newSize]; 
     [myWebView setFrameSize:newSize]; 
    } 


    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
    { 
     // Insert code here to initialize your application 

[self.window setContentView:self.myWebView]; 

[self.window toggleFullScreen:@""]; 

[myWebView setMainFrameURL:@"http://www.mywebgameurl.com"]; 

    } 


    @end 

분명, - (void)magnifyWithEvent:(NSEvent *)event 내부의 코드가 작동하지 않습니다 : 그건 내 appDelegate.M입니다. 앱이 만들어지고 실행되지만, 집어 넣을 때 아무 일도 일어나지 않습니다.

즉, 트랙 패드 핀치 기능을 사용하여 웹보기를 확대 및 축소 할 수 있어야합니다. 나는 이미 Android에서 매우 비슷한 웹 뷰를 개발했으며, 수행해야 할 작업은 모두 webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true);입니다. 나는 그저 그런 것을 찾고 있습니다. 어떤 도움도 환영합니다, 감사합니다 !!

답변

0

당신은 할 수 없습니다. 코코아 웹 뷰는 핀치 줌 기능을 제어 할 수 없습니다.

관련 문제