Develop
2015.02.10 18:41
[ios] UIWebView에서 로컬에 있는 html 파일 불러오기
조회 수 971 댓글 0
로컬에 있는 html 파일을 불러오는 방법!!
일단 웹뷰에서 보고자하는 html 파일을 프로젝트에 추가.
아래와 같은 코드로 로컬에 있는 html 파일을 읽어와서 웹뷰에 내용을 출력할 수 있다.
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, width, height)]; NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"파일명" ofType:@"html"]; NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile]; [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURLURLWithString:@""]]; [self.view addSubview:webView];
-----------
팁!
webView에 라운드 주는 방법!
QuartzCore 프레임워크를 임포트하고 라운드 속성을 넣어준다.
#import <QuartzCore/QuartzCore.h> [[webView layer] setCornerRadius:10]; [webView setClipsToBounds:YES]; [[webView layer]setBorderColor: [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor]]; [[webView layer] setBorderWidth:2.75];
[출처] http://bananamilk.tistory.com/197
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
145 | Develop | [js] 후리자(영규) 스타일들.. | hooni | 2013.04.23 | 7174 |
144 | Develop | [js]모바일 웹에서 orientationchange | hooni | 2013.04.23 | 19429 |
143 | Develop | [kotlin] 코틀린 안드로이드 앱 버전/빌드 정보 | hooni | 2020.12.15 | 979 |
142 | Develop | [lego] 세그웨이 이것만 볼것.. ㅎㅎ | hooni | 2013.04.23 | 33577 |
141 | Develop | [linux] CentOS Apache 웹서버에 HTTPS 적용 | hooni | 2015.10.23 | 914 |
140 | Develop | [linux] crond 사용법.. ㅋㅋ | hooni | 2013.04.23 | 7272 |
139 | Develop | [linux] tar 명령어 뽀개기.. ㅋㅋ | hooni | 2003.04.23 | 7788 |
138 | Develop | [linux] 날짜나 파일의 내용으로 검색하는 방법(find 명령 사용) | hooni | 2013.04.23 | 8148 |
137 | Develop | [linux] 쉘 스크립트를 이용한 BBS | hooni | 2003.04.23 | 10080 |
136 | Develop | [linux] 임베디드 리눅스 (embedded linux) | hooni | 2013.04.23 | 7382 |
135 | Develop | [linux] 프로세스 관련 시스템콜 | hooni | 2003.04.23 | 7871 |
134 | Develop | [matlab] ZigZag-Scanning (2-D Array) | hooni | 2016.10.15 | 2109 |