【问题标题】:Change the accessorytype of all the row of UITableView改变UITableView所有行的accessorytype
【发布时间】:2011-05-24 07:02:53
【问题描述】:

我想在单击栏按钮项时更改 UITableView 的所有单元格的附件类型。对此有什么想法或代码。

【问题讨论】:

    标签: iphone uitableview didselectrowatindexpath accessorytype


    【解决方案1】:

    只需拿一个标志(一个布尔值或其他东西)并在您的表格视图上调用 reloadData 。并在 cellForRowAtIndexPath 中测试您的标志并放置您想要的任何附件。

    【讨论】:

      【解决方案2】:

      tableView:cellForRowAtIndexPath:

      ...
      if ( selected ) {
          cell.accessoryType = UITableViewCellAccessoryCheckmark;
      }
      ...
      

      单击条形按钮项时,

      ...
      selected = YES;
      [self.tableView reloadRowsAtIndexPaths:[self.tableView visibleCells] withRowAnimation: UITableViewRowAnimationNone];
      ...
      

      【讨论】:

        【解决方案3】:
        - (UITableViewCell  *)tableView:(UITableView  *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath {
            // some code
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            return cell;
            }
        

        您可以在其中检查您的状况并将电池的附件类型更改为具有以下任何值

        typedef enum {
           UITableViewCellAccessoryNone,
           UITableViewCellAccessoryDisclosureIndicator,
           UITableViewCellAccessoryDetailDisclosureButton,
           UITableViewCellAccessoryCheckmark
        } UITableViewCellAccessoryType;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-08-11
          • 1970-01-01
          • 2011-09-12
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多