Contents

조회 수 949 댓글 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
번호 분류 제목 글쓴이 날짜 조회 수
733 Develop [js] URL 파싱하기 (jQuery 안쓰고) hooni 2017.12.14 1308
732 Develop [php] 한글 문자열 자르기 (utf-8) hooni 2015.11.10 1319
731 Develop [android] 간단한 SQLIite 예제 hooni 2017.06.14 1325
730 Develop How to Test SMTP AUTH using Telnet hooni 2018.04.05 1335
729 Develop [ios] How to set up clang formatter hooni 2015.09.17 1360
728 Develop [swift] popToRoot 모달뷰, 네비게이션컨트롤러 한꺼번에 닫기 file hooni 2021.01.29 1383
727 Develop [ios] Swift 4 String, Date, DateFormatter 예제 hooni 2018.10.18 1396
726 Develop What is difference between Get, Post, Put and Delete? hooni 2018.02.28 1403
725 Develop [android] 레이아웃 사이즈 변경 (동적; programmatically) hooni 2016.11.07 1482
724 Develop [ios] Pod 특정 버전 설치하고 사용하기 hooni 2022.05.28 1527
723 Develop [ios] binary를 C코드로 변환 file hooni 2015.01.03 1527
722 Develop [python] 파라미터 앞에 *, ** 의 의미? (*args, **kwargs) hooni 2019.11.22 1553
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 ... 71 Next
/ 71