Contents

조회 수 2177 댓글 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"]];
}



?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
519 Develop [c] 도메인 소켓(Unix Domain Socket) UDP file hooni 2013.04.23 10174
518 Develop [c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ file hooni 2013.04.23 10127
517 Develop [php] 초간단 게시판 페이지 분할 알고리즘 hooni 2003.04.23 10117
516 Develop [js] 폼(form) 전송시 중복 클릭 방지 간단한 구문 hooni 2013.04.23 10113
515 Develop [c] 파일(File)의 연결과 연결 해제 (link, unlink, chown) hooni 2013.04.23 10103
514 Develop [c] 공용체를 이용해 MSB를 LSB로 변환 file hooni 2013.04.23 10091
513 Develop [c] OpenGL 직사각형(2D) 크기 확대/축소 hooni 2003.04.23 10088
512 Develop [c][cpp] mfc, win32api, 예제 소스 대박 모음~ file hooni 2013.04.23 10026
511 Develop [c][java] 주사선 채우기 알고리즘(scan line filling algorithm) 구현 file hooni 2013.04.23 10026
510 Develop [c] OpenGL 마우스 이벤트 hooni 2003.04.23 10023
509 Develop [java] 채팅창 처럼.. swing.. file hooni 2013.04.23 9998
508 Develop [c] 컴파일러 DFA구현^^ 입력 받아 실행 4 file hooni 2003.04.23 9977
Board Pagination Prev 1 ... 23 24 25 26 27 28 29 30 31 32 ... 71 Next
/ 71