Develop
2015.02.10 18:41
[ios] UIWebView에서 로컬에 있는 html 파일 불러오기
조회 수 959 댓글 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
957 | Develop | [ios] 카메라 사용 권한 확인해서 분기하는 방법 | hooni | 2015.02.26 | 1942 |
956 | Develop | [ios] Objective-C 에서 자주 사용하는 수학 함수와 유용한 Define | hooni | 2014.08.08 | 1945 |
955 | Develop |
[iOS] 시뮬레이터에 푸시 알림을 보내는 방법
![]() |
hooni | 2021.10.13 | 1956 |
954 | Develop | [swift] UIView에서 subview 찾기 | hooni | 2022.12.09 | 1968 |
953 | Develop |
[android] 가속도 센서를 이용한 흔듦(Shake) 감지
![]() |
hooni | 2014.11.04 | 1984 |
952 | Develop |
[ios] 웹뷰 history.back() ㅋㄷ
![]() |
hooni | 2016.06.27 | 2000 |
951 | System/OS | 맥 OS X 에서 스크린 화면 캡쳐 단축키 (Mac Print Screen) | hooni | 2015.07.21 | 2012 |
950 | Etc |
영어. 반드시 외워야 할 단어
![]() |
hooni | 2016.07.07 | 2042 |
949 | Develop |
[ios] 카테고리 확장 메소드를 찾지 못하는 경우
![]() |
hooni | 2014.08.08 | 2057 |
948 | System/OS |
iptime 공유기 해킹 기술문서
4 ![]() |
hooni | 2015.01.01 | 2058 |
947 | Develop | [php][laravel] 초간단 MacOS에서 Laravel 개발 환경 구축 | hooni | 2017.12.15 | 2071 |
946 | Develop |
[c#] mfc 기반의 웹서비스 서버/클라이언트 샘플과 예제 소스
![]() |
hooni | 2013.04.23 | 2073 |