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"]]; }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
1077 | Develop |
[Xcode] 디버깅 옵션
![]() |
hooni | 2013.04.23 | 57246 |
1076 | Develop |
[winmobile] 윈도우 모바일 간단한 테스트 코드 ㅋㅋ
![]() |
hooni | 2013.04.23 | 17109 |
1075 | System/OS | [windows] 패스워드를 잊어먹었을때.. | hooni | 2003.04.23 | 17343 |
1074 | System/OS | [windows] 최근 열어본 문서목록 안나오게 하는 방법 | hooni | 2013.04.23 | 25552 |
1073 | System/OS | [windows] 종료, 재시작, 로그아웃 아이콘 만들기 | hooni | 2013.04.23 | 18185 |
1072 | System/OS |
[windows] 인터넷 익스플로러(IE) 도구모음 표시줄에 아이콘 추가
![]() |
hooni | 2013.04.23 | 18276 |
1071 | System/OS | [windows] 윈도우즈 콘솔에서 정품인증 하는 방법 | hooni | 2017.05.24 | 5519 |
1070 | System/OS |
[windows] 윈도우 사용자 계정 로그인 암호 분실, 암호 변경하는 방법
![]() |
hooni | 2015.07.09 | 21504 |
1069 | System/OS | [windows] 원격 데스크탑(터미널 서비스) 포트 변경 | hooni | 2013.04.23 | 16349 |
1068 | System/OS | [windows] 여러가지 활용 팁 | hooni | 2003.04.23 | 20023 |
1067 | System/OS | [windows] 배치(bat)파일 제작 방법 | hooni | 2003.04.23 | 17052 |
1066 | System/OS | [windows] 도스 사용 팁 | hooni | 2003.04.23 | 17888 |