【问题标题】:Swift iframe not loading in web viewSwift iframe 未在 Web 视图中加载
【发布时间】:2015-10-05 23:24:31
【问题描述】:

基本上,在 web 视图中,我的页面加载正常,但其中的 iframe 永远不会加载,它们只是保持白色或根本不出现,这在 htmlstrings 和 NSURL 会话中都会发生,请帮助。 代码

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.
}


}

【问题讨论】:

    标签: ios swift iframe webview


    【解决方案1】:
        @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

    【讨论】:

    • 有什么快速的吗?
    猜你喜欢
    • 2013-03-05
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 2013-11-01
    相关资源
    最近更新 更多