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
237 Develop [c#] BHO 한샘툴바랑 동현툴바.. secret hooni 2013.04.23 2208
236 Develop [ios] 기본 네비게이션바의 타이틀, back버튼 위치와 속성 변경 file hooni 2016.05.16 2200
235 Develop [android] SQLiteOpenHelper를 이용한 DBManager hooni 2017.06.14 2198
234 Develop [ios] 설정에서 푸시 알림(APNS) on/off 상태 확인 hooni 2015.04.28 2160
233 Develop [c#] 툴바 최근 버전(IE6, IE7 두가지 버전) secret hooni 2013.04.23 2138
232 Develop [java] netty (비동기 이벤트 방식 네트워크 프레임워크) 사용법 #2 (client) hooni 2015.01.02 2135
231 Develop [ios] Swift 4 Dictionary 사용하기 file hooni 2018.11.29 2134
230 Develop [php][laravel] 초간단 MacOS에서 Laravel 개발 환경 구축 hooni 2017.12.15 2130
229 Develop [swift] UIView에서 subview 찾기 hooni 2022.12.09 2124
228 Develop [matlab] ZigZag-Scanning (2-D Array) file hooni 2016.10.15 2122
227 Develop [ios] 카테고리 확장 메소드를 찾지 못하는 경우 file hooni 2014.08.08 2121
226 System/OS iptime 공유기 해킹 기술문서 4 file hooni 2015.01.01 2094
Board Pagination Prev 1 ... 74 75 76 77 78 79 80 81 82 83 ... 98 Next
/ 98