基本上,在网页视图中,我的网页加载正常,但其中的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.
}
}
答案 0 :(得分: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替换为您的实际网址