1
UIWebView
を使用するをで実装したかったのですが、問題はUIWebViewに動画が表示されないということです。私はレッスンhttps://w%20ww.youtube.com/watch?v=rcVv1N1hReQの後に繰り返してみましたが、それは不可能です。UIWebViewに埋め込まれたYouTube動画が再生されない
UIWebView
を使用するをで実装したかったのですが、問題はUIWebViewに動画が表示されないということです。私はレッスンhttps://w%20ww.youtube.com/watch?v=rcVv1N1hReQの後に繰り返してみましたが、それは不可能です。UIWebViewに埋め込まれたYouTube動画が再生されない
コード
var testArray = ["https://www.youtube.com/embed/W7qWa52k-nE", "https://www.youtube.com/embed/vH7i-qpoFVk", "https://www.youtube.com/embed/V_GTrL-UVmE"]
override func viewDidLoad() {
super.viewDidLoad()
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return testArray.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! WebViewTableViewCell
cell.videoWeb.allowsInlineMediaPlayback = true
let embededHTML = "<html><body><iframe src=\"\(testArray[indexPath.row])?playsinline=1\" width=\"'\(cell.videoWeb.frame.width)'\" height=\"'\(cell.videoWeb.frame.height)'\" frameborder=\"10\" allowfullscreen></iframe></body></html>"
cell.videoWeb.loadHTMLString(embededHTML, baseURL: NSBundle.mainBundle().bundleURL)
cell.videoWeb.scrollView.scrollEnabled = false
return cell
}
スクリーン
テストプロジェクト
あなたの質問はありますか? – henrikstroem