0
나는 프로그래밍 방식으로 HTML의 필드 값을 설정하는 소스 코드 예제를 가지고있다. 내가 프로그래밍 실제로 페이스 북 대신에 위에서 작성과 같은 사용자 정의 HTML과 같은 상세 페이지의 필드의 값을 설정하려는UIWebView - Facebook 같은 웹 페이지에서 HTML 코드를 추출하는 방법은 무엇입니까?
- (void)viewDidLoad
{
[super viewDidLoad];
myWebView.delegate = self;
//---formulate the HTML string---
NSString *str = [[[NSString alloc] initWithString:
@"<html>"
" <body>"
" <h1>The fields below are filled in programmatically</h1>"
" <input id='username' value='UserName' />"
" <input id='password' value='Password' type='password' />"
" </body>"
"</html>"
] autorelease];
//---load the UIWebView with the html string---
[myWebView loadHTMLString:str baseURL:nil];
}
//---wait for the UIWebView to finish loading---
- (void)webViewDidFinishLoad:(UIWebView *)webView {
//---access the 2 fields in the HTML---
[myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('username').value='Wei-Meng Lee';"];
[myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('password').value='TopSecret';"];
}
: 소스 코드의
부분은 같은 것입니다.
"str"을 실제 웹 페이지의 HTML 소스 코드로 바꾸어 "ElementbyId"를 선택할 수 있습니까? [UIWebView loadRequest]
와
//---formulate the HTML string---
NSString *str = [[[NSString alloc] initWithString:
@"<html>"
" <body>"
" <h1>The fields below are filled in programmatically</h1>"
" <input id='username' value='UserName' />"
" <input id='password' value='Password' type='password' />"
" </body>"
"</html>"
] autorelease];
//---load the UIWebView with the html string---
[myWebView loadHTMLString:str baseURL:nil];
를 교체하고는 URL과 웹보기를로드되고있는 UIWebView가 stringByEvaluatingJavaScriptFromString
작품을 만들기 위해 HTML을 포함하여
HTML 대신 URL에서 웹 페이지를 여는 중입니까? – Zakaria
URL에서 웹 페이지를 열고 stringByEvaulatingJavaScriptFromString 함수를 사용할 수 있습니다. – at0m87