Develop
2015.02.10 18:08
[ios] 로컬에 있는 JS 파일 웹뷰에서 동적으로 실행하기
조회 수 2177 댓글 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"]]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
519 | Develop |
[c] 도메인 소켓(Unix Domain Socket) UDP
![]() |
hooni | 2013.04.23 | 10174 |
518 | Develop |
[c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ
![]() |
hooni | 2013.04.23 | 10127 |
517 | Develop | [php] 초간단 게시판 페이지 분할 알고리즘 | hooni | 2003.04.23 | 10117 |
516 | Develop | [js] 폼(form) 전송시 중복 클릭 방지 간단한 구문 | hooni | 2013.04.23 | 10113 |
515 | Develop | [c] 파일(File)의 연결과 연결 해제 (link, unlink, chown) | hooni | 2013.04.23 | 10103 |
514 | Develop |
[c] 공용체를 이용해 MSB를 LSB로 변환
![]() |
hooni | 2013.04.23 | 10091 |
513 | Develop | [c] OpenGL 직사각형(2D) 크기 확대/축소 | hooni | 2003.04.23 | 10088 |
512 | Develop |
[c][cpp] mfc, win32api, 예제 소스 대박 모음~
![]() |
hooni | 2013.04.23 | 10026 |
511 | Develop |
[c][java] 주사선 채우기 알고리즘(scan line filling algorithm) 구현
![]() |
hooni | 2013.04.23 | 10026 |
510 | Develop | [c] OpenGL 마우스 이벤트 | hooni | 2003.04.23 | 10023 |
509 | Develop |
[java] 채팅창 처럼.. swing..
![]() |
hooni | 2013.04.23 | 9998 |
508 | Develop |
[c] 컴파일러 DFA구현^^ 입력 받아 실행
4 ![]() |
hooni | 2003.04.23 | 9977 |