Contents

?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

JS 파일을 프로젝트로 추가하고 UIWebView 딜리게이트를 처리하는 내용

- (void)webViewDidStartLoad:(UIWebView *)webView{
    ...
    // JS파일들을 동적으로 추가하는 내용의 함수 호출
    [self injectJSCodes];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    ....

    // JS 함수가 잘 로드되고 실행 되는지 확인
    NSString *jsString1 = @"picomax.alert('2100411931200932');";
    [_webView stringByEvaluatingJavaScriptFromString:jsString1];
    
    NSString *jsString2 = @"OcbiOSJS.showBarcodeScanPopup('2100411931200932');";
    [_webView stringByEvaluatingJavaScriptFromString:jsString2];
}

- (void)injectJSWithPath:(NSString *)path
{
    //현재 프로젝트의 리소스 파일의 경로 얻기.
    //NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    //NSString *path = [[NSBundle mainBundle] pathForResource:@"OcbiOSJS" ofType:@"js"];
    NSLog(@"js path : %@", path);
    NSString *jsString = [[NSString alloc] initWithContentsOfFile:path
        encoding:NSUTF8StringEncoding error:nil];

    [_webView stringByEvaluatingJavaScriptFromString:jsString];
}

- (void)injectJSCodes
{
    [self injectJSWithPath:[[NSBundle mainBundle]
        pathForResource:@"OcbiOSJS" ofType:@"js"]];

    [self injectJSWithPath:[[NSBundle mainBundle]
        pathForResource:@"OcbiOSTitleViewJS" ofType:@"js"]];
}



?

List of Articles
No. Category Subject Author Date Views
957 Develop [ios] GMT Date와 Local Date 변환하기 hooni 2015.04.07 825
956 Etc 아이폰의 터치스크린 정확도 file hooni 2015.04.01 1410
955 Develop [ios] 아이폰 앱 이름 및 버전 정보 hooni 2015.03.24 846
954 Develop [ios] 카메라 사용 권한 확인해서 분기하는 방법 hooni 2015.02.26 1867
953 PPT [ppt] iOS 플라랩#01(2015.02.26) 발표 자료 file hooni 2015.02.25 727
952 Develop [ios] Touch ID 적용 샘플 코드 (예제) file hooni 2015.02.23 664
951 Develop [펌] 게임 엔진 만든거 공개합니다. hooni 2015.02.21 2350
950 Develop [ios] StoryBoard(xib) 없이 프로젝트 만들기 file hooni 2015.02.12 1063
949 Develop [ios] UIWebView에서 로컬에 있는 html 파일 불러오기 hooni 2015.02.10 889
» Develop [ios] 로컬에 있는 JS 파일 웹뷰에서 동적으로 실행하기 hooni 2015.02.10 947
947 Develop [ios] 로컬에 있는 html 실행하기 hooni 2015.02.10 1026
946 Develop [ios] 앱의 로컬 js 파일에서 해당 프로젝트의 이미지 불러오기 hooni 2015.02.10 623
Board Pagination Prev 1 ... 14 15 16 17 18 19 20 21 22 23 ... 98 Next
/ 98