webview에서의 방법(javascript, post데이터 전송)등
1. 일반적인 로딩
NSString * address = @http://www.naver.com;
NSURL *url = [[NSURL alloc]initWithString:address];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[mWebView loadRequest:request];
2. javascript 실행
NSMutableString * javascript = [NSMutableString stringWithString:@"alert('');"];
[mWebView stringByEvaluatingJavaScriptFromString:javascript];
3. WebView에 Post 데이터 실어보내기!!
NSString * address = @http://www.naver.com;
NSURL *url = [[NSURL alloc]initWithString:address];
NSString *postdata = [NSString stringWithFormat:@"post=%@", @"data"];
NSMutableURLRequest *request = [NSMutableURLRequest alloc]initWithURL:url];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postdata dataUsingEncoding:NSUTF8StringEncoding]];
[mWebView loadRequest:request];
4. JS file
you can also call a JS file from a bundle (get around that readability snag and have as many fnctions as you need)….
NSString *filePath = [[NSBundle mainBundle] pathForResource:@”loco” ofType:@”js” inDirectory:@”"];
NSData *fileData = [NSData dataWithContentsOfFile:filePath];
NSString *jsString = [[NSMutableString alloc] initWithData:fileData encoding:NSUTF8StringEncoding];
[webby stringByEvaluatingJavaScriptFromString:jsString];
'컴퓨터 > 아이폰' 카테고리의 다른 글
[ios6]앱스토어 모달로 불러오기 (0) | 2013.01.09 |
---|---|
[iPhone SDK] 현재 전화의 상태를 알아오기 (0) | 2013.01.08 |
아이폰 페이스 북과 트위터 연동 (0) | 2012.12.27 |
MRImageViewer -> 이미지 슬라이드 예제 (0) | 2012.12.26 |
tableview 관련 (0) | 2012.11.26 |