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"]];
}



?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
381 Develop [c] 도메인(호스트)으로 IP정보 알아오기.. (nslookup과 비슷) file hooni 2013.04.23 6934
380 Develop [c] 숫자 맞추는 게임.. file hooni 2013.04.23 6932
379 Develop [c] 단기과정[01/06] sizeof, 실수표현, 메모리, 연산자 hooni 2003.04.23 6928
378 Develop [php] 빔 프로젝터 예약 프로그램.. ㅋㅋ file hooni 2013.04.23 6924
377 Develop [c] 소켓의 세가지 동작모드 hooni 2003.04.23 6911
376 Develop [c] 프로세스 정보 출력하기.. file hooni 2003.04.23 6908
375 Develop [c] 맵서치인 듯(옛날 컴에서 찾은 자료) file hooni 2013.04.23 6904
374 Develop [c] 단기과정[01/10] 과제.. swap(any data, ..) file hooni 2003.04.23 6904
373 Develop [c] pcapdump 파일 분석 하는 프로그램.. ㅋㅋ file hooni 2013.04.23 6900
372 Develop [c] 프로세스간의 통신(파이프) hooni 2003.04.23 6891
371 Develop [c] 간단한 순위 루틴.. (정보처리기사) hooni 2003.04.23 6874
370 Develop [c] 라인수 입력받아 마름모꼴 출력하기.. hooni 2003.04.23 6869
Board Pagination Prev 1 ... 62 63 64 65 66 67 68 69 70 71 ... 98 Next
/ 98