is it possible to use iframe in UIWebView?

后端 未结 2 899
半阙折子戏
半阙折子戏 2021-02-15 05:47

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 U

相关标签:
2条回答
  • 2021-02-15 06:31

    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.

    0 讨论(0)
  • 2021-02-15 06:35

    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.

    0 讨论(0)
提交回复
热议问题