2016-05-01 19 views

答えて

0

コード

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 
    } 

スクリーン

enter image description here

テストプロジェクト

test project link

関連する問題