我在表视图中有UIScrollViews(包含十个单元格的表视图)..在每个UIScrollView中,我有九个webview(每页树)。我的问题是:当表视图向下滚动时... webview内容以意想不到的方式出现..数据没有出现在正确的位置(indexPath.row在另一个indexPath.row的位置)我想我不能设置可重用的单元格大概..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathk {
ArticlestableView.separatorStyle = UITableViewCellSeparatorStyleNone;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
previewScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(5, 20, 648, 185)];
[previewScrollView setContentSize:CGSizeMake(1944, 185)];
previewScrollView.backgroundColor = [UIColor clearColor];
previewScrollView.pagingEnabled = YES;
previewScrollView.tag = 000;
float margin = 5.0;
float offset = margin;
for (int i=0; i < 9; i ++) {
NSLog(@"i : %i",i);
int arrayIndex = i;
CGRect frame1 = CGRectMake(offset, 0.0, 206, 180 );
Node =[[UIWebView alloc] initWithFrame:frame1];
Node.delegate = self;
Node.userInteractionEnabled = NO;
Node.opaque = NO;
Node.backgroundColor = [UIColor clearColor];
Node.tag = [[NSString stringWithFormat:@"111%i%i",indexPath.row,i] intValue];
[previewScrollView addSubview:Node];
[Node release];
offset= offset + 216;
}
previewScrollView.showsHorizontalScrollIndicator = NO;
previewScrollView.showsVerticalScrollIndicator = NO;
CGPoint bottomOffset = CGPointMake([previewScrollView contentSize].width-previewScrollView.frame.size.width,0 );
[previewScrollView setContentOffset: bottomOffset animated: NO];
[[cell contentView] addSubview:previewScrollView];
}
previewScrollView = (UIScrollView *)[cell.contentView viewWithTag:000];
for (int j=0; j < 9; j ++) {
int arrayIndex = j;
Node = (UIWebView *)[previewScrollView viewWithTag:[[NSString stringWithFormat:@"111%i%i",indexPath.row,j] intValue]];
Node.delegate = self;
str = [NSString stringWithFormat:@"%i",indexPath.row];
[Node loadHTMLString:str baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
btnTitle = (UIButton *)[cell.contentView viewWithTag:[btnTitleTag intValue]];
}
return cell;
}
任何帮助都将不胜感激。
答案 0 :(得分:0)
一个问题是使用标记0,因为所有视图都将该标记作为默认标记。