is it possible to use iframe in UIWebView?

后端 未结 2 910
半阙折子戏
半阙折子戏 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条回答
  •  猫巷女王i
    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 = @"";
    
        // 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.

提交回复
热议问题