Develop
2015.02.10 18:41
[ios] UIWebView에서 로컬에 있는 html 파일 불러오기
조회 수 883 댓글 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
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
757 | Develop | [js] 키보드 아스키코드(ASCII) 코드보기 | hooni | 2003.04.23 | 32476 |
756 | Develop | [js] 이벤트 핸들러(Event Handlers) | hooni | 2003.04.23 | 6728 |
755 | Develop | [js] 사라지는 브라우저 | hooni | 2003.04.23 | 6857 |
754 | Develop | [c] OpenGL 마우스 이벤트 | hooni | 2003.04.23 | 8731 |
753 | Develop | [js] 점점 커지는 새창.. | hooni | 2003.04.23 | 6998 |
752 | Develop | [c][java] 소켓 프로그래밍(채팅 서버 C, 클라이언트 Java) | hooni | 2003.04.23 | 7011 |
751 | Develop | [c] 신기한 atoi함수(www.game79.net) | hooni | 2003.04.23 | 7273 |
750 | Develop | [c] OpenGL 색 입방체의 회전(입체) | hooni | 2003.04.23 | 7869 |
749 | Develop | [php] 마시마로 캐릭터 방명록 | hooni | 2003.04.23 | 8239 |
748 | Develop | [c] 시간 계산 하는 프로그램 소스코드 | hooni | 2003.04.23 | 6745 |
747 | Develop | [linux] 프로세스 관련 시스템콜 | hooni | 2003.04.23 | 7827 |
746 | Develop | [c] 문자열 처리 관련 함수들 설명 | hooni | 2003.04.23 | 7997 |