我有一个带静态单元格的TableView,其头部有4个单元格,中间有一个单元格带有UIWebView,页面有一个带注释的页面。每个评论都有它自己的单元格。 我的问题是如果页脚有4个或更多注释,则页脚中的第4个单元格与中间的单元格相同。
我的cellForRowAtIndexPath如下所示:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Get cell
static NSString *CellIdentifier = @"CellA";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
UITableViewCell *contentCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (contentCell == nil) {
contentCell = [[CustomDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Display
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.font = [UIFont systemFontOfSize:15];
if (item) {
// Item Info
NSString *itemTitle = item.title ? [item.title stringByConvertingHTMLToPlainText] : @"[No Title]";
// Display
switch (indexPath.section) {
case SectionHeader: {
// Header
switch (indexPath.row) {
case SectionHeaderTitle:
cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
cell.textLabel.text = itemTitle;
cell.textLabel.numberOfLines = 0; // Multiline
break;
case SectionHeaderDate:
cell.textLabel.text = dateString ? dateString : @"[Kein Datum]";
cell.imageView.image = nil;
break;
case SectionHeaderSharerFacebook:
cell.textLabel.text = @"Share on Facebook";
cell.imageView.image = [UIImage imageNamed:@"f_logo.png"];
break;
case SectionHeaderSharerTwitter:
cell.textLabel.text = @"Share on Twitter";
cell.imageView.image = [UIImage imageNamed:@"twitter-bird-blue-on-white.png"];
}
break;
}
case SectionDetail: {
//add webView to your cell
if (webViewDidFinishLoad == TRUE && indexPath.section != SectionComments) {
CGFloat contentHeight = webView.scrollView.contentSize.height;
webView.frame = CGRectMake(23, 10, 275, contentHeight);
} else {
webView.frame = CGRectMake(23, 10, 275, 10);
}
cell.backgroundColor = [UIColor whiteColor];
[cell addSubview:webView];
break;
}
case SectionComments: {
NSString *writerText = [[[self.commentParser.commentsArray objectAtIndex:indexPath.row] name] stringByAppendingString:@" schrieb:\n"];
writerText = [writerText stringByAppendingString:[[self.commentParser.commentsArray objectAtIndex:indexPath.row] description]];
writerText = [writerText stringByAppendingFormat:@"\n"];
cell.textLabel.text = writerText;
cell.imageView.image = nil;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0; //multiline
if (cell.textLabel.text == nil) {
cell.textLabel.text = @"Keine Kommentare vorhanden";
cell.textLabel.font = [UIFont fontWithName:@"Verdana-Italic" size:12];
}
break;
}
}
return cell;
}
}
为什么UIWebView再次位于第4个单元格中,如何更改?
感谢您的每一个答案!