Closed davidslakter closed 7 years ago
Solution to YouTube:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let currentVideo = youtubeVideos[indexPath.row]
let videoURL = "https://www.youtube.com/embed/\(currentVideo.videoID)"
let cell = tableView.dequeueReusableCell(withIdentifier: "videoCell", for: indexPath) as! YouTubeVideoCell;
cell.selectionStyle = .none
// Set the video view
cell.videoView.scrollView.contentInset = UIEdgeInsets.zero
// cell.videoView.loadHTMLString("<iframe width=\"\(cell.videoView.frame.width)\" height=\"\(cell.videoView.frame.height)\" src=\"\(videoURL)?&playsinline=0\" frameborder=\"0\" allowfullscreen></iframe>", baseURL: nil)
let url = URL(string: videoURL)
let request = URLRequest(url: url!, cachePolicy: .returnCacheDataElseLoad, timeoutInterval: 15.0)
cell.videoView.loadRequest(request)
cell.videoView.allowsInlineMediaPlayback = false
cell.videoView.scrollView.isScrollEnabled = false
cell.channelName.text = currentVideo.channelTitle
cell.datePosted.text = currentVideo.datePublished.stringValueShort
cell.setProfilePicture(imageURL: URL(string: (YouTubePreviewUser?._profilePictureUrl)!)!)
return cell
}
the current way of retrieving and setting data in these table views has bug. The cells load with incorrect information from previously loaded cells.