title: Youtube Videos in tableview cells
body: <p>I currently have a tableview with YouTube videos embedded inside of the custom cells.</p>
  
  <p>I did this because from my research it seemed like the only way to allow the videos to load without leaving my application.</p>
  
  <p>The problem is this</p>
  
  <p>The thumbnails take a while to load. As I scroll down the list of videos, it keeps having to load the thumbnails. If I scroll back up, it tries to load the video thumbnails yet again.</p>
  
  <p>Has anyone got any suggestions on either better ways of doing this, or ways of getting the table cells to keep the data and not replace it?</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>-(UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
  
  static NSString *MyIdentifier = @"MyIdentifier";
  
  YouTubeCell *cell = (YouTubeCell*)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
  if(cell ==nil){
  
      cell = [[[YouTubeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
  
  }
  NSDictionary *dic = [youTubeArr objectAtIndex:indexPath.row];
  [cell updateCellData:dic];
  return cell;
  
  }
  
  -(void)updateCellData:(NSDictionary*)dict
  {
  NSDictionary *tempDic = [dict objectForKey:@"video"];
  self.titleLbl.text = [tempDic objectForKey:@"title"];
  NSString *viewCountStr = [NSString stringWithFormat:@"%@ views -",[tempDic objectForKey:@"viewCount"]];
  viewCountLbl.text = viewCountStr;
  uploadedDateLbl.text = [tempDic objectForKey:@"uploaded"];
  
  NSDictionary *videoDic = [tempDic objectForKey:@"player"];
  NSString *videoStr = [NSString stringWithFormat:@"%@",[videoDic objectForKey:@"default"]]; 
  
  NSString *embedHTML = 
  @"&lt;html&gt;&lt;head&gt;\
  &lt;body style=\"margin:0\"&gt;\
  &lt;embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
  width=\"%0.0f\" height=\"%0.0f\"&gt;&lt;/embed&gt;\
  &lt;/body&gt;&lt;/html&gt;";
  
  // videoView = [[UIWebView alloc] initWithFrame:CGRectMake(3, 5, 100, 60)]; initialzed in ///initwithstyle of cell
  
  NSString *html = [NSString stringWithFormat:embedHTML, videoStr, videoView.frame.size.width, videoView.frame.size.height];
  [videoView loadHTMLString:html baseURL:nil];
  
  }
  </code></pre>