Мое приложение вылетает с сообщением "изменение слоя, который завершается" после прокрутки в представлении таблицы.
Я полагаю, что ошибка связана с тем, что я выпустил 'videoView' (вторая последняя строка кода) в конце метода.
Как я могу решить эту проблему?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* PlaceholderCellIdentifier = @"PlaceholderCell";
GenericObject *youTubeVid = [self.searchResultArray objectAtIndex:indexPath.row];
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier]autorelease];
}
UIWebView *videoView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 104, 104)];
NSString *cellid=[NSString stringWithFormat:@"Cell%i%i", indexPath.section, indexPath.row];
if([self.webViewCache objectForKey:cellid])
{
videoView=[self.webViewCache objectForKey:cellid];
}
else
{
NSString *url = [NSString stringWithFormat:@"http://www.youtube.com/watch?v=%@",youTubeVid.vid];
NSString *videoHTML = [self embedYouTube:url frame:CGRectMake(0, 0, 104, 104)];
[videoView loadHTMLString:videoHTML baseURL:nil];
[self.webViewCache setObject:videoView forKey:cellid]; //Save webview in dictionary
}
[cell.contentView addSubview:videoView];
//Error seems to be here
[videoView release];
return cell;
}