투케이2K

153. (Objective-C/objc) [간단 소스] NSURL fileURLWithPath 사용해 WKWebview 웹뷰 NSBundle html 파일 로드 수행 본문

Objective-C

153. (Objective-C/objc) [간단 소스] NSURL fileURLWithPath 사용해 WKWebview 웹뷰 NSBundle html 파일 로드 수행

투케이2K 2024. 9. 20. 20:19
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : OBJECTIVE-C

 

[소스 코드]

 

    // ----------------------------------------------------------------------
    // [사전 준비 사항] 
    // ----------------------------------------------------------------------
    // 1. 특정 html 파일 준비
    // ----------------------------------------------------------------------
    // 2. html 파일을 프로젝트 내부에 추가 실시
    // ----------------------------------------------------------------------





    // ----------------------------------------------------------------------
    // [소스 코드] 
    // ----------------------------------------------------------------------
    // [특정 html 파일 경로 지정] : 파일 명칭 : twok.html
    NSString *urlStr =  [[NSBundle mainBundle] pathForResource:@"twok" ofType:@"html"];
    
    // [특정 파일 경로 URL 지정 실시 : fileURLWithPath]
    NSURL * url = [NSURL fileURLWithPath:urlStr];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
    
    // [WKWebview html 파일 로드 수행]
    [webView loadRequest:request];
    // ----------------------------------------------------------------------

 

반응형
Comments