0
我已成功添加UIWebView
到UIAlertView
,并在警报弹出窗口中显示Html页面。 但现在我想跟踪UIWebView
中的元素。那么你能告诉我怎么才能知道哪个UIButton
被点击了UIWebView
显示在alert
弹出窗口?将UIWebView添加到UIAlertView iOS
代码:
NSString *html [email protected]"<!DOCTYPE html><html><body><form action=\"action_page.php\">First name:<br><input type=\"text\" name=\"firstname\"><br> Last name:<br> <input type=\"text\" name=\"lastname\"><br><br> <input type=\"submit\"> </form> <p>Note that the form itself is not visible.</p> <p>Also note that the default width of a text field is 20 characters.</p> </body> </html>";
UIWebView *webView = [[UIWebView alloc] init];
[webView setFrame:CGRectMake(0,0,200,400)];
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
[webView loadData:data MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"www.google.com"]];
webView.delegate = self;
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[av setValue:webView forKey:@"accessoryView"];
[av show];
我已经加入的UIWebView使用语法UIAlertView中: UIAlertView中* AV = [[UIAlertView中的alloc] initWithTitle:@ “TEST” 消息:@ “子视图” delegate:nil cancelButtonTitle:@“NO”otherButtonTitles:@“YES”,nil]; [av setValue:webView forKey:@“accessoryView”]; [av show]; – Sumit 2014-12-05 05:43:35
是的,对于那个UIviewWeb,您可以将委托给当前视图。 – Esha 2014-12-05 05:44:21
将相同的代码添加到您的问题中,以使其更清晰。您可以将委托设置为'webView.delegate = self'并为web视图添加协议。可能是解决你的点击事件。 – Esha 2014-12-05 05:47:13