-2

你好。我构建了我的应用程序,并在领事馆中查看了此错误:

警告:由于 tableView:accessoryTypeForRowWithIndexPath: in 的委托实现而使用旧版单元格布局。请删除此方法的实现并设置单元格属性附件类型和/或编辑附件类型以移动到新的单元格布局行为。在以后的版本中将不再调用此方法。

代码是:

      - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
     {
    return 1;
      }

     - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
      return [name count];
     }


     // Customize the appearance of table view cells.
     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    // Set up the cell...
    NSString *cellValue = [name objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    /*NSString *trimmedString = [[listOfItems objectAtIndex:indexPath.row] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    NSString *website4 = [NSString stringWithFormat:@"http://shaymargolisapps.x10.mx/send.php?mission=GetImageOfApp&aname=%@", trimmedString]; 
    NSData *dataURL4 = [NSData dataWithContentsOfURL:[NSURL URLWithString:website4]];
    NSString *strResult4 = [[[NSString alloc] initWithData:dataURL4 encoding:NSUTF8StringEncoding]autorelease];
    NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:strResult4]];
    UIImage* image = [[UIImage alloc] initWithContentsOfFile:@"%@PlaceholderApp.png"];
    [cell.imageView setImage:image];*/
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //Get the selected country
    NSString *selectedCountry = [name objectAtIndex:indexPath.row];

    //Initialize the detail view controller and display it.
    DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
    dvController.selectedCountry = selectedCountry;
    [self.navigationController pushViewController:dvController animated:YES];
    [dvController release];
    dvController = nil;
         }

          - (UITableViewCellAccessoryType)tableView:(UITableView *)tableView             accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {

        //return UITableViewCellAccessoryDetailDisclosureButton;
         return UITableViewCellAccessoryDisclosureIndicator;
              }

          - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *)indexPath {

            [self tableView:tableView didSelectRowAtIndexPath:indexPath];
                  }

什么问题?

4

1 回答 1

2

这意味着它所说的。您正在使用已弃用的方法。删除此方法的实现:

-(UITableViewCellAccessoryType)tableView:(UITableView *)tableView             accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath

改为在 cellForRowAtIndexPath 中设置附件类型:

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

我现在看到你已经在做。

于 2012-06-02T14:41:26.737 回答