Develop
2015.02.10 18:41
[ios] UIWebView에서 로컬에 있는 html 파일 불러오기
조회 수 881 댓글 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
733 | Develop | [opengl] 컴퓨터 그래픽스 강의 자료(수업자료) | hooni | 2003.04.23 | 20432 |
732 | Develop | [android] [번역] 안드로이드 Android Cloud to Device Messaging(C2DM) | hooni | 2013.04.23 | 20419 |
731 | Develop | [php] substr() 한글 자를 때 깨짐 방지 | hooni | 2014.01.09 | 20359 |
730 | Develop | [ios] UIView에서 상위 UIViewController 가져오기 | hooni | 2013.09.27 | 20136 |
729 | Develop | [c] UTF-8을 EUC-KR로 변환.. (iconv) | hooni | 2013.04.23 | 20115 |
728 | Develop | [c] AES 알고리즘 (암호화/복호화) | hooni | 2003.04.23 | 20046 |
727 | Develop | [php] XE 에서 php 구문 사용하기 (XE 템플릿에서) | hooni | 2013.10.31 | 19431 |
726 | Develop | [js]모바일 웹에서 orientationchange | hooni | 2013.04.23 | 19355 |
725 | Develop | 모터에 대한 pid 제어.. ㅎㅎ | hooni | 2013.04.23 | 18873 |
724 | Develop | URI 인코딩, URL 인코딩 | hooni | 2013.04.23 | 18841 |
723 | Develop | [ios] Objective-C에서 형식이 있는 문자열(Format Strings)에 사용할 수 있는 토큰들(Tokens) | hooni | 2013.04.23 | 18781 |
722 | Develop | [ios] libxml/tree.h file not found | hooni | 2013.08.08 | 18708 |