【问题标题】:Hide Row(Multiple Row) After Clicked in TableView在 TableView 中单击后隐藏行(多行)
【发布时间】:2014-07-29 13:28:24
【问题描述】:

我正在开发一个应用程序。此应用程序包含 TableView 如果我在某些操作后单击要隐藏的行中的任何一行,任何人都可以帮忙吗?

【问题讨论】:

    标签: ios ios7 ios5 ios4 ios6


    【解决方案1】:

    我有一个建议给你:

    @property (nonatomic, strong) NSArray   *tableItems;
    @property (nonatomic) NSInteger         hideIndex;
    

    在 didSelectRowAtIndex 方法中添加 UITableView 委托方法

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    // Store index of row to hide.
    self.hideIndex = indexPath.row;   
    }
    

    创建你的操作方法

    - (void) doOperation {
    
    // Remove index from table datasource.
    @try {
        NSMutableArray *tempArray = [NSMutableArray arrayWithArray:self.tableItems];
        [tempArray removeObjectAtIndex:self.hideIndex];
    
        self.tableItems = [NSArray arrayWithArray:tempArray];
        tempArray = nil;
        [self.tableView reloadData];
    }
    @catch (NSException *exception) {
        NSLog(@"Handle exception");
    }
    }
    

    这样在下次重新加载 UITableView 时将显示剩余的单元格。并删除您选择的单元格。

    【讨论】:

      猜你喜欢
      • 2019-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多