Develop
2015.02.10 18:41
[ios] UIWebView에서 로컬에 있는 html 파일 불러오기
조회 수 966 댓글 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
73 | Develop | [c#] HTML 이벤트 샘플 소스.. | hooni | 2013.04.23 | 7770 |
72 | Develop | [c#] Hashtable <-> Json (dll 포함) | hooni | 2013.04.23 | 80713 |
71 | Develop | [c#] BHO 한샘툴바랑 동현툴바.. | hooni | 2013.04.23 | 2208 |
70 | Develop | [c#] BFilter 툴바 소스 코드 ㅎㅎ | hooni | 2013.04.23 | 7649 |
69 | Develop | [asp] 폼메일 예제와 메일 포워딩 프로그램 | hooni | 2013.04.23 | 7153 |
68 | Develop | [asp] 폼 메일 소스 | hooni | 2013.04.23 | 7381 |
67 | Develop | [asp] 문자열 넘겨받기 (get,post) | hooni | 2013.04.23 | 8740 |
66 | Develop | [asp] 문자열 관련 함수 요약 | hooni | 2013.04.23 | 7799 |
65 | Develop | [asp] 기본 문법과 제어문 | hooni | 2013.04.23 | 7132 |
64 | Develop | [asem] CMOS 패스워드 알아내기.. 소스.. | hooni | 2003.04.23 | 8747 |
63 | Develop | [api] 인스타그램에서 최신 이미지 가져오기 (Using Instagram API) 20 | hooni | 2018.04.05 | 12550 |
62 | Develop | [api] 인스타그램 API Access_Token 발급 방법 (Instagram API) 3 | hooni | 2018.04.05 | 7689 |