2012-06-09 21 views
0

我有一个代表,但它不没有其他委托线在它的工作:我该如何解决这个委托错误?

- (id)initWithData:(NSData *)data delegate:(id <ParseOperationDelegate>)theDelegate { 

    self = [super init]; 

    if (self != nil) { 
     self.dataToParse = data; 
     self.delegate = theDelegate; 
    } 

    appDelegate = (XMLAppDelegate *)[[UIApplication sharedApplication] delegate]; 

    return self; 
} 

应该加载数据在一个小区,但第一涡旋之前的数据未示出。我能做什么?

编辑:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"productCell"; 
    static NSString *PlaceholderCellIdentifier = @"placeholderCell"; 

    int nodeCount = [appDelegate.products count]; 

    if (nodeCount == 0 && indexPath.row == 0) { 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier]; 
     if (cell == nil) { 
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PlaceholderCellIdentifier]; 
      cell.detailTextLabel.textAlignment = UITextAlignmentCenter; 
      cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
     } 

     cell.detailTextLabel.text = @"Loading..."; 

     return cell; 
    } 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    if (nodeCount > 0) { 
     XMLProductView *listedProduct = [appDelegate.products objectAtIndex:indexPath.row]; 

     cell.textLabel.text = listedProduct.name; 
     // cell.detailTextLabel.text = appRecord.artist; 

     if (!listedProduct.productImage) { 
      if (self.tableView.dragging == NO && self.tableView.decelerating == NO) { 
       [self startImageDownload:listedProduct forIndexPath:indexPath]; 
      } 
      UIImageView *listedImage = (UIImageView *)[cell viewWithTag:1]; 
      listedImage.image = [UIImage imageNamed:@"Placeholder.png"]; 
     } 
     else { 
      UIImageView *listedImage = (UIImageView *)[cell viewWithTag:1]; 
      listedImage.image = listedProduct.productImage; 
     } 

    } 

    return cell; 
} 
+0

请更具体一点,其他代表是什么行? –

+0

当你说“它应该加载单元格中的数据”时,我看不到代码。我们是否也需要查看“cellForRowAtIndexPath:”方法的代码? –

+0

@OmarAbdelhafith我的PaseOperationDelegate是一个私人ID代理。当我删除appDelegate =(XMLAppDelegate *)...单元格甚至没有填充。这是我的问题。 – filou

回答

2

你的代码似乎它等待某个事件,或者一些文件让牵强或下载的,所以你需要调用[tableview reloadData];当这个数据被下载,

我不能弄明白从代码,但我的胆量告诉我这

1: 你是从int nodeCount = [appDelegate.products count];等待数据准备好,所以你需要有某种形式的代表,可推动CAL导致当这个数据准备

第二: 你正在等待图像到这里下载[self startImageDownload:listedProduct forIndexPath:indexPath],所以,当这实际上获取下载您需要设置图像到该小区或reloadData在桌子上

这是我可以从代码中找出的。

相关问题