Views 949 Votes 0 Comment 0
?

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
405 Etc [link] 유용한 사이트 링크. hooni 2013.08.19 71451
404 System/OS [linux] /etc/fstab 설정 방법.. ㅋㅋ hooni 2013.04.23 12081
403 System/OS [linux] apache, php, jsp 환경설정하기.. hooni 2003.04.23 15232
402 System/OS [linux] APM(apache, php, mysql) + gd 설치순서.. hooni 2003.04.23 18851
401 System/OS [linux] awk 명령어 hooni 2014.03.11 4955
400 System/OS [linux] CentOS 6.5 에서 "Bringing up interface eth0: Determining if ip address 121.78.127.197 is already in use for device eth0..." hooni 2014.04.05 4838
399 System/OS [linux] CentOS 6.x Cati 설치 (yum) hooni 2014.01.17 48594
398 System/OS [linux] CentOS Apache Httpd에 https 적용 hooni 2014.03.05 4480
397 Develop [linux] CentOS Apache 웹서버에 HTTPS 적용 hooni 2015.10.23 783
396 System/OS [linux] CentOS 에 APM 설치하기 hooni 2015.01.02 1688
395 System/OS [linux] CentOS 터미널 언어 설정(한글/영어) hooni 2013.12.22 18513
394 Develop [linux] crond 사용법.. ㅋㅋ hooni 2013.04.23 7246
393 System/OS [linux] DHCP(Dynamic Host Configuration Protocol) 서버 hooni 2003.04.23 13023
392 System/OS [linux] DNS(Domain Name System) 설치, 설정 hooni 2003.04.23 12438
391 System/OS [linux] GD 라이브러리 설치 방법.. file hooni 2013.04.23 11370
390 System/OS [linux] iconv를 이용하여 euc-kr 문서를 utf-8로 대량으로 변환하기 file hooni 2014.01.09 12219
Board Pagination Prev 1 ... 47 48 49 50 51 ... 74 Next
/ 74