Contents

?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

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
No. Category Subject Author Date Views
1077 Develop [android] 간단한 SQLIite 예제 hooni 2017.06.14 1454
1076 Develop 캘리포니아 운전면허 족보 file hooni 2017.06.12 867
1075 Develop 사이버보안실무 발표자료 (2017.06.08) file hooni 2017.06.05 1333
1074 System/OS [windows] 윈도우즈 콘솔에서 정품인증 하는 방법 hooni 2017.05.24 5557
1073 Develop 리팩토링 계획안 file hooni 2017.05.15 854
1072 Develop [ios] 코코아 프로그래밍의 네이밍 룰(명명 규칙) hooni 2017.05.11 1271
1071 Etc 사이버보안실무 시험. secret hooni 2017.04.20 0
1070 Develop [ios] Facebook SDK 로그인 설명 file hooni 2017.04.19 1301
1069 Develop [ios] NSString, RegularExpression Find/Replace hooni 2017.04.14 937
1068 Develop [ios] 비디오,네트워크,소셜로그인 테스트 file hooni 2017.04.04 777
1067 Etc 사이버보안실무 수업 메모 hooni 2017.03.30 925
1066 Database [mysql] 쿼리 실행시 ERROR 1366 (HY000) : incorrect string value : for column 3 hooni 2017.03.30 8916
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 ... 98 Next
/ 98