【问题标题】:UITableView CellsUITableView 单元格
【发布时间】:2012-06-02 14:18:49
【问题描述】:

你好。我构建了我的应用程序并在控制台中查看了此错误:

警告:由于 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];
                  }

什么问题?

【问题讨论】:

    标签: objective-c ios cocoa-touch uitableview


    【解决方案1】:

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

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

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

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    

    我现在看到你已经在做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多