Contents

조회 수 958 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

JS 파일을 프로젝트로 추가하고 UIWebView 딜리게이트를 처리하는 내용

- (void)webViewDidStartLoad:(UIWebView *)webView{
    ...
    // JS파일들을 동적으로 추가하는 내용의 함수 호출
    [self injectJSCodes];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    ....

    // JS 함수가 잘 로드되고 실행 되는지 확인
    NSString *jsString1 = @"picomax.alert('2100411931200932');";
    [_webView stringByEvaluatingJavaScriptFromString:jsString1];
    
    NSString *jsString2 = @"OcbiOSJS.showBarcodeScanPopup('2100411931200932');";
    [_webView stringByEvaluatingJavaScriptFromString:jsString2];
}

- (void)injectJSWithPath:(NSString *)path
{
    //현재 프로젝트의 리소스 파일의 경로 얻기.
    //NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    //NSString *path = [[NSBundle mainBundle] pathForResource:@"OcbiOSJS" ofType:@"js"];
    NSLog(@"js path : %@", path);
    NSString *jsString = [[NSString alloc] initWithContentsOfFile:path
        encoding:NSUTF8StringEncoding error:nil];

    [_webView stringByEvaluatingJavaScriptFromString:jsString];
}

- (void)injectJSCodes
{
    [self injectJSWithPath:[[NSBundle mainBundle]
        pathForResource:@"OcbiOSJS" ofType:@"js"]];

    [self injectJSWithPath:[[NSBundle mainBundle]
        pathForResource:@"OcbiOSTitleViewJS" ofType:@"js"]];
}



?

  1. [mac] OS X 요세미티 사용자가 많이 겪는 버그와 몇몇 불편사항

  2. [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기

  3. 개인적으로 쓰고 있는 bash_profile

  4. [maven] Mac OS에 메이븐(maven) 설치하기

  5. [php] XE에서 도메인 별로 광고 다르게 적용하기

  6. [php] XE 스킨에서 특정 도메인 리다이렉션

  7. [js] 2048 예쁘게 만들고 있는거.. ㅋㄷ

  8. [ios] URL 랜딩 속도(OpenURL 10초 정지되는) 이슈

  9. [ios] 문자열로 함수 실행하기 (eval 함수처럼)

  10. [ios] 앱의 로컬 js 파일에서 해당 프로젝트의 이미지 불러오기

  11. [ios] 로컬에 있는 html 실행하기

  12. [ios] 로컬에 있는 JS 파일 웹뷰에서 동적으로 실행하기

Board Pagination Prev 1 ... 74 75 76 77 78 79 80 81 82 83 ... 98 Next
/ 98