Develop
2015.02.10 18:08
[ios] 로컬에 있는 JS 파일 웹뷰에서 동적으로 실행하기
조회 수 958 댓글 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"]]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
741 | Develop | [doc] mfc 매뉴얼 다운 받아서 완성하기.. ㅋㄷ | hooni | 2013.04.23 | 7708 |
740 | System/OS | [doc] TCP/IP 강의 자료 (html) | hooni | 2013.04.23 | 11171 |
739 | Develop | [doc] UI개발시 유용한 소프트웨어 (개발 및 디버깅 툴) | hooni | 2013.04.23 | 12913 |
738 | System/OS | [doc] 네트워크 장비와 라우터 설정 방법 발표 자료 | hooni | 2013.04.23 | 14495 |
737 | PPT | [doc] 논문.. VoIP 관련.. ㅋㅋ | hooni | 2013.04.23 | 17081 |
736 | System/OS | [doc] 레드햇 리눅스 메뉴얼 (html버전) | hooni | 2013.04.23 | 10452 |
735 | PPT | [doc] 발표 자료 ㅎㅎtalk4neo | hooni | 2013.04.23 | 20992 |
734 | PPT | [doc] 방송통신공학회 논문지(학술대회) | hooni | 2013.04.23 | 13927 |
733 | Etc | [doc] 웜 프레임워크 검증환경 구축(작성중..) | hooni | 2013.04.23 | 16013 |
732 | PPT | [doc] 위탁과제 제안서와 발표자료(pdf) | hooni | 2013.04.23 | 12534 |
731 | Develop | [doc] 유료 방송 제어 시스템 (CAS) 발표자료 | hooni | 2013.04.23 | 8511 |
730 | PPT | [doc] 인공지능 관련 자료(채팅로봇도 포함..) | hooni | 2013.04.23 | 18003 |