Develop
2015.02.10 18:41
[ios] UIWebView에서 로컬에 있는 html 파일 불러오기
조회 수 895 댓글 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
781 | Develop | [swift] 실행시간 측정하기 | hooni | 2021.09.14 | 676 |
780 | Develop | [swift] UIView에서 subview 찾기 | hooni | 2022.12.09 | 1771 |
779 | Develop | [swift] popToRoot 모달뷰, 네비게이션컨트롤러 한꺼번에 닫기 | hooni | 2021.01.29 | 1386 |
778 | Develop | [swift] NotificationCenter 간단 예제 | hooni | 2021.01.27 | 8115 |
777 | Develop | [spring] 스프링 IoC/DI | hooni | 2013.04.23 | 11347 |
776 | Develop | [sh] 쉘스크립트 if 비교 연산 | hooni | 2020.05.26 | 59872 |
775 | Develop | [sh] html 안에 있는 img 다운 받는 쉘 스크립트 | hooni | 2020.05.26 | 640 |
774 | Develop | [python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기) | hooni | 2019.12.06 | 1690 |
773 | Develop | [python] 파이썬 공부하는 사이트~ | hooni | 2013.11.12 | 10842 |
772 | Develop | [python] 파라미터 앞에 *, ** 의 의미? (*args, **kwargs) | hooni | 2019.11.22 | 1553 |
771 | Develop | [python] 애니팡, 캔디팡 매크로 | hooni | 2013.09.06 | 17322 |
770 | Develop | [python] DJI Tello 드론 코딩 (프로그래밍) 58 | hooni | 2018.03.04 | 25769 |