Develop
2015.02.10 17:37
[ios] 앱의 로컬 js 파일에서 해당 프로젝트의 이미지 불러오기
조회 수 738 댓글 0
UIWebView의 딜리게이터 내용
- (void)webViewDidFinishLoad:(UIWebView*)webView { //현재 프로젝트의 리소스 파일의 경로 얻기. NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; // getImagePath와 같은 js파일 안의 메소드. NSString *tmpStr = [NSString stringWithFormat:@"getImagePath('%@')", resourcePath]; // 문자열을 인코딩, 경로상에 공백과 같은 부분이 있을때 이를 해결. tmpStr = [tmpStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // 실행. [webView stringByEvaluatingJavaScriptFromString:tmpStr]; }
JS 파일 내용
function getImagePath( _imgPath ) { //앞에서 넘겨 받은 경로뒤에 원하는 이미지명을 입력. addCSSRule('.highlight_color1', 'background-image: url('+ _imgPath +'/bg_highlightpen_1.png);'); }
[출처] http://egloos.zum.com/sungsmy/v/2428366
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
697 | Develop | [c++] 인라인 함수 설명과 예제.. | hooni | 2013.04.23 | 6674 |
696 | Develop | [c++] 인라인 함수에 대한 설명 | hooni | 2013.04.23 | 7136 |
695 | Develop | [c++] 자료구조(링크리스트,스택,큐)와 후위 표기 계산기 샘플 ㅋㅋ 4 | hooni | 2013.04.23 | 12358 |
694 | Develop | [c++] 중복실행 방지(Mutex;뮤텍스 ) 샘플 소스.. ㅋㅋ | hooni | 2013.04.23 | 8770 |
693 | Develop | [c++] 채팅로봇 소스.. ㅋㄷㅋㄷ | hooni | 2013.04.23 | 8906 |
692 | Develop | [c++] 초간단 스택 두 가지 방식(class, struct) | hooni | 2013.04.23 | 7638 |
691 | Develop | [c++] 템플릿(Template) 예제 소스.. | hooni | 2013.04.23 | 7004 |
690 | Develop | [c++] 트리컨트롤 스텝 2 예제.. | hooni | 2013.04.23 | 6984 |
689 | Develop | [c++] 트리컨트롤 스텝 3 예제.. | hooni | 2013.04.23 | 7969 |
688 | Develop | [c++] 트리컨트롤 예제1 ㅋㅋ | hooni | 2013.04.23 | 7197 |
687 | Develop | [c++] 퍼즐 버블버블 간단한 원리(사용공식) | hooni | 2013.04.23 | 10003 |
686 | Develop | [c++] 프리렉(freelec) 예제 자료.. ㅋㄷ | hooni | 2013.04.23 | 6860 |