ios - Swift iframe 未在 Web View 中加载

标签 ios swift iframe webview

基本上,在网页 View 中,我的页面加载正常,但其中的 iframe 从未加载,它们只是保持白色或根本不显示,这种情况发生在 htmlstrings 和 NSURL session 中,请帮忙。 代码

import Darwin
import UIKit

class ViewController: UIViewController {
@IBOutlet var InterfaceX: UIWebView!
override func viewDidLoad() {
    super.viewDidLoad()
    sleep(1)

    let url=NSBundle.mainBundle().URLForResource("hi", withExtension: "html")
    //let url = NSURL(string: "http://creepertech.net/xe/interface")
    let request = NSURLRequest(URL: url!)
    InterfaceX.loadRequest(request)
    InterfaceX.allowsInlineMediaPlayback = true;

    //let htm:String! = "<head><header></header></head><body><iframe src=\"http://xegaming.com\"></iframe></body>"
    //InterfaceX.loadHTMLString(htm, baseURL: nil)


    // Do any additional setup after loading the view, typically from a nib.
}
override func prefersStatusBarHidden() -> Bool {
    return true
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

最佳答案

    @IBOutlet weak var m_objWebView: UIWebView!

func CreateWebViewPlayer()
    { 
     self.m_objWebView.allowsInlineMediaPlayback = true

     let embededHTML = "<html><body><iframe src=\"URL HERE\"?playsinline=1\" width=\"320\" height=\"315\" frameborder=\"0\" scrolling=\"no\" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe></body></html>"

     self.m_objWebView.loadHTMLString(embededHTML, baseURL: NSBundle.mainBundle().bundleURL)
    }

注意:- 将此处的 URL 替换为您的实际 URL

关于ios - Swift iframe 未在 Web View 中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32959423/

相关文章:

ios - 如果解析用户已登录,则绕过登录 View

javascript - 多个网站上的单个 HTML5 表单

ios - iCarousel 无限滚动和索引重置

ios - 未知类型名称 NSURLSession

ios - 关闭推送通知

ios - UITableViewCell 中的 Reactive<UISegmentedControl>

javascript - 使用javascript的iframe问题

javascript - Angular 5 阻止 iframe 谷歌地图

ios - ViewController 不符合协议(protocol) AnyObject 错误与 UISwipeGestureRecognizer

ios - Parse.com 快速重置推送通知角标(Badge)