UIWebView in UITableView reloads everytime I scrol

2019-09-04 11:53发布

问题:

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.