Develop
2015.02.10 18:08
[ios] 로컬에 있는 JS 파일 웹뷰에서 동적으로 실행하기
조회 수 1061 댓글 0
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"]]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
265 | Develop | [c] 프로세스간의 통신(파이프) | hooni | 2003.04.23 | 6905 |
264 | Develop | [c] 라인수 입력받아 마름모꼴 출력하기.. | hooni | 2003.04.23 | 6897 |
263 | Develop | [c] 간단한 순위 루틴.. (정보처리기사) | hooni | 2003.04.23 | 6894 |
262 | Develop |
[js] 수명체크 프로그램 ㅋㅋ
![]() |
hooni | 2013.04.23 | 6891 |
261 | Develop | [js] 사라지는 브라우저 | hooni | 2003.04.23 | 6876 |
260 | Develop | [ajax] 샘플 코드와 한글처리에 대한 간단한 설명 | hooni | 2013.04.23 | 6867 |
259 | Develop |
[pdf] 윈도우즈 95 시스템 프로그래밍(Windows 95 system programming)
![]() |
hooni | 2013.04.23 | 6864 |
258 | Develop | [js] get방식, url이후 모두 그대로 읽어오기.. | hooni | 2013.04.23 | 6860 |
257 | Develop |
[c] 단기과정[01/14] 파일 입출력
![]() |
hooni | 2003.04.23 | 6856 |
256 | Develop | [js] 숫자만 입력하게 하는 자바스크립트 | hooni | 2013.04.23 | 6849 |
255 | Develop |
[c] 문자열 str_shift 예제..
![]() |
hooni | 2013.04.23 | 6849 |
254 | Develop |
[c++] 프리렉(freelec) 예제 자료.. ㅋㄷ
![]() |
hooni | 2013.04.23 | 6848 |