【问题标题】:UITableViewCell cell.editingAccessoryType not workingUITableViewCell cell.editingAccessoryType 不起作用
【发布时间】:2010-01-24 08:35:35
【问题描述】:

我有一个表格视图。它设置和工作的一切。 我有 cell.accessoryType 工作正常,但我没有一次让 cell.editingAccessoryType 工作。 它适用于不推荐使用的方法,但使用新方法......没有运气。 这是我的代码,至少是第一部分:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;

开关(indexPath.section) {
案例 RFE_SECTION: 开关(indexPath.row) { 案例0: { 静态 NSString *RFECellIdentifier = @"RFECellIdentifier";

cell = [tableView dequeueReusableCellWithIdentifier:RFECellIdentifier];

if (cell == nil) 
{
 // Create a cell to display "Add Visit".
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RFECellIdentifier] autorelease];
 cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
 cell.textLabel.numberOfLines = 0;
 cell.textLabel.font = [UIFont fontWithName:@"American Typewriter" size:16.0f];
}
if (visit.rfe.length == 0) 
{
 cell.textLabel.text = @"Add Reason for Encounter";
}
if (visit.rfe.length != 0) 
{
 cell.textLabel.text = visit.rfe;
}

} 休息; } 休息;

下一节,等等,等等,等等。

每当我将editingAccessoryType 放入时,我都会去编辑tableView,但它并没有显示出来。有任何想法吗?我错过了一些委托方法吗?

我也有一个 - (void)setEditing:(BOOL)editing Animation:(BOOL)animated 方法设置。那会有什么不同吗? 我现在有点迷路了。 提前致谢。

【问题讨论】:

    标签: iphone uitableview


    【解决方案1】:

    鉴于您重复使用单元格,请确保为每个单元格设置 accessoryTypeeditingAccessoryType 并注释掉 -tableView:accessoryTypeForRowWithIndexPath:。如果没有任何反应,请在 -tableView:cellForRowAtIndexPath: 中注释掉所有单元格设置代码,返回一个带有附件的空单元格。

    【讨论】:

    • 我都做到了。将我的方法简化为最简单的术语。 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *RFECellIdentifier = @"RFECellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RFECellIdentifier]; if (cell == nil) { // 创建一个单元格以显示“添加访问”。 cell = [[[UITableViewCell alloc] init] autorelease]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.editingAccessoryType = UITableViewCellAccessoryNone;返回单元格; } 仍然没有骰子
    • 另外,我没有使用 UITableViewController @interface VisitDetailViewController : UIViewController 我这里有什么遗漏吗?
    • 将 cell.editingAccessoryType 设置为 UITableViewCellAccessoryNone 隐藏 编辑时附件,这解释了为什么在进入编辑状态时看不到任何附件。这是预期的行为。尝试将其设置为任何其他值以确保其正常工作。
    【解决方案2】:

    确保你没有设置 cell.editing=YES; 看起来很直观,但会搞乱整个工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      • 2018-03-14
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多