Я создал список видео на Youtube, но есть некоторые проблемы:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *url = [selectedCellItem.content objectAtIndex:indexPath.row];
UIWebView *wbView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, ROW_HEIGHT, ROW_HEIGHT)];
wbView.tag = 1;
[cell.contentView addSubview:wbView];
[wbView release];
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML,url, ROW_HEIGHT, ROW_HEIGHT];
UIWebView *thisVideoView = (UIWebView *)[cell.contentView viewWithTag:1];
thisVideoView.delegate = self;
[thisVideoView loadHTMLString:html baseURL:nil];
CGFloat cellWidth = [UIScreen mainScreen].bounds.size.width-ROW_HEIGHT-5;
NSString *cellValue = [selectedCellItem.title objectAtIndex:indexPath.row];
CGRect labelFrame = CGRectMake(ROW_HEIGHT+5, 0.0, cellWidth, ROW_HEIGHT);
UILabel *titleLabel = [[UILabel alloc] initWithFrame:labelFrame];
titleLabel.tag = 2;
titleLabel.text = cellValue;
titleLabel.font = [UIFont systemFontOfSize:14.0];
[titleLabel setNumberOfLines:10];
[cell.contentView addSubview:titleLabel];
[titleLabel release];
return cell;
}
В начале мое приложение работает просто отлично. Однако, когда я нажимаю одну ячейку несколько раз, метка начинает перекрываться с метками других ячеек. Как я могу решить эту проблему?