Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to use iframe in UIWebView?

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.

like image 402
Piscean Avatar asked Mar 02 '11 13:03

Piscean


People also ask

Is UIWebView deprecated?

As of iOS 12.0, 'UIWebView' has been explicitly marked as deprecated. Apple is encouraging developers to adopt WKWebView instead, which was introduced in iOS 8.0.

What does UIWebView mean?

Android is powered by Chrome. Mobile Safari UIWebView. The UIWebView is different from the ordinary Safari browser, as it is not a stand-alone browser, but merely browser functionality that is embedded in a third party app that allows the app to display content from the web.

What is use of UIWebView or WKWebView?

Difference Between UIWebview and WKWebViewUIWebview is a part of UIKit, so it is available to your apps as standard. You don't need to import anything, it will we there by default. But WKWebView is run in a separate process to your app,. You need to import Webkit to use WKWebView in your app.

How do I use WKWebView?

Here's how: Open the XIB or Storyboard you want to add the web view to in Interface Builder. Find the web view or WKWebView in the Object Library at the bottom-left of Interface Builder. Drag-and-drop a WKWebView object from the Object Library to your view controller's canvas, and adjust its size and position.


1 Answers

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.

like image 195
Sameera Chathuranga Avatar answered Oct 25 '22 01:10

Sameera Chathuranga