【问题标题】:Warning in table view表格视图中的警告
【发布时间】:2010-07-21 07:59:09
【问题描述】:

我在视图控制器中使用表格视图,简单的数组显示在列表中。该数组已显示并且工作正常,但我收到此警告。我可以知道这是什么原因,并请一些想法来纠正这个问题..

警告:由于委托实现而使用旧版单元格布局 表视图:accessoryTypeForRowWithIndexPath:在。请删除您对此方法的实现并设置 要移动的单元格属性附件类型和/或编辑附件类型 到新的单元格布局行为。该方法将不再被调用 在未来的版本中。

谢谢

【问题讨论】:

  • 在您接受之前问题的一些答案之前,我什至不会阅读您的问题 :)
  • 嗨 willcodejavaforfood 请指导我如何接受答案。我无法理解你的意思...

标签: ios xml xcode uitableview


【解决方案1】:

tableView:accessoryTypeForRowWithIndexPath: 方法在 iPhone OS 3.0 中已弃用。删除该方法的实现,在方法@​​987654322@中添加如下代码:

cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

其他类型请参阅文档中的UITableViewCellAccessoryType

【讨论】:

  • 嗨,Mathieuf,因为没有足够的空间,我已经在答案选项卡中回答了,请检查我的代码。我犯了错误谢谢你的建议!!!
  • 方法tableView:accessoryTypeForRowWithIndexPath: 删除了吗?
  • 是的,我已经删除了 MathieuF,现在它没有显示该警告,非常感谢:P
【解决方案2】:

我正在使用您提到的以下代码:

// 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...
    cell.text = [arry objectAtIndex:indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

    return cell;
}

但它返回相同

【讨论】:

    【解决方案3】:

    它只是说这个方法将在下一个版本中消失,所以你应该去文档寻找 tableView:accessoryTypeForRowWithIndexPath ,你肯定会找到做你想做的事情的替代方法。

    换句话说,通过调用 UITableViewCell 附件视图和附件类型属性来设置该单元格的附件

    myCell.accessoryType = ...
    myCell.accessoryView = ...
    

    【讨论】:

    • 嗨,Nacho,由于没有足够的空间,我已经在答案选项卡中回答了,请检查我的代码。我犯了错误谢谢你的建议!!!
    猜你喜欢
    • 2011-03-18
    • 2013-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    相关资源
    最近更新 更多