UIWebView in UITableView reloads everytime I scroll. How do I prevent it from reloading?

北城余情 提交于 2019-12-11 19:19:11

问题


Currently I have a UITableView that has a UIWebView in every cell. Each UIWebView is loading a unique embedded YouTube video. Is there a way to keep the UIWebView from reloading when scrolling. It looks cheaply developed when it scrolls on screen and is a white rectangle to loading a video thumbnail. I was looking into UIWebView caching but I don't know how I would go about caching the WebView to reuse it later.


回答1:


You can try this differently, just define new table view cell for that particular index like

UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil] retain];

see if that makes a difference you desire




回答2:


Keep a reference to the UITableViewCell somewhere (an array in your UITableViewController, for example), and return the existing cell in the cellForRowAtIndexPath call, instead of de-queueing a new cell.



来源:https://stackoverflow.com/questions/17203101/uiwebview-in-uitableview-reloads-everytime-i-scroll-how-do-i-prevent-it-from-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!