2011-09-23 106 views
0

我有表视图(含10个单元表视图)..里面UIScrollViews在每个UIScrollView中我有九个网页视图(每页树)。我的问题是:当表视图向下滚动..the的WebView内容出现在意想不到的方式。该数据不会出现在正确的位置(indexPath.row在另一indexPath.row的现在的位置),我想我不能设置可重复使用的电池大概..的UIWebView里面的UIScrollView里面的UITableViewCell

- (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

感谢答复vakio .. 我试图改变标签000到另一个..但在broplem仍在发生。 – smaiibnauf

+0

哪里是最后一篇文章?是否被海报删除?!! – smaiibnauf

+0

是的,他删除了它后,我给了他一个反对票。 – vakio