问题
i want to add a facebook like button in my app. in developer.facebook.com i couldn't fine anything about that. is it possible to use iframe created by facebook like button in UIWebView? it think if its possible then i can add a UIWebView in my app which use that iframe. thanx. please write some example code.
回答1:
Yes that is possible you can use the iframe in webview. You need to load the webview with the HTML string. You can also find the related code of HTML for iframe if you search over the net. Moreover you can also use javascript, in webview using the method stringByEvaluatingJavaScript
: of UIWebview.
回答2:
Yes it is possible, I am using iFrame to load youtube Video inside the app.
Following simple steps will guide you to achieve it.
Step 1 : Create a UIWebView in xib
Step 2 : Connect it to your ViewController's .h file. (I am referring it as _wevView in my project).
Step 3 : Create a method embedYouTube
in your ViewController's .m file.
-(void)embedYouTube {
// Read create a NSString object with iframe
NSString *embedHTML = @"<iframe width=\"300\" height=\"250\" src=\"http://www.youtube.com/embed/rOPI5LDo7mg\" frameborder=\"0\" allowfullscreen></iframe>";
// Initialize the html data to webview
[_webView loadHTMLString:embedHTML baseURL:nil];
// Add webview to your main view
[self.view addSubview:_webView];
}
Step 4: Add the webview to your main view by by making a call to the method embedYouTube
inside viewDidLoad
[self embedYouTube];
Step 5: Compile and run the app. You should be able to view the YouTube player embedded in the page.
来源:https://stackoverflow.com/questions/5167907/is-it-possible-to-use-iframe-in-uiwebview