Contents

조회 수 1077 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
517 Develop [c] 가변인자 함수(printf와 같은..) hooni 2013.04.23 7199
516 Develop [php] 탐색기와 같은 다이나믹 트리(xml/xsl 이용) file hooni 2013.04.23 7201
515 Develop [c] 시스템공학 레포트 (pass1, pass2) file hooni 2003.04.23 7203
514 Develop [c] 시스템 보안 과제.. 시간(amc time) 변경 file hooni 2013.04.23 7204
513 Develop [c++] template 사용예 hooni 2003.04.23 7206
512 Develop [c] 함수 목록과 예제 소스 파일 file hooni 2013.04.23 7210
511 Develop [c] 네트워크 관련 프로그래밍 (포트스캔 탐지 샘플) file hooni 2013.04.23 7216
510 Develop [c] 문자열 라이브러리 최신버전 file hooni 2003.04.23 7222
509 Develop [jsp] 초간단한 include 구문 예제.. file hooni 2013.04.23 7244
508 Develop [js] 네이버에서 그림 퍼올 때.. URL Encoding 관련ㅋㅋ hooni 2013.04.23 7245
507 Develop [c] 심심해서.. fseek() 예제.. file hooni 2003.04.23 7254
506 Develop [c] 단기과정[01/17] 후위연산 스택 계산기.. file hooni 2003.04.23 7255
Board Pagination Prev 1 ... 23 24 25 26 27 28 29 30 31 32 ... 71 Next
/ 71