Ios 如何基于首先点击的原始单元格循环5个UITableView单元格

Ios 如何基于首先点击的原始单元格循环5个UITableView单元格,ios,objective-c,Ios,Objective C,我有一个应用程序,它在表格视图中以单元格的形式列出一些数据。我希望用户能够选择一个表视图单元格,任意一个,并让应用程序循环通过5个较低的单元格。以下是我到目前为止的情况: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // Navigation logic may go here. Create and push another view contr

我有一个应用程序,它在表格视图中以单元格的形式列出一些数据。我希望用户能够选择一个表视图单元格,任意一个,并让应用程序循环通过5个较低的单元格。以下是我到目前为止的情况:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    // Navigation logic may go here. Create and push another view controller.

    [self fetchCellsToProcess:indexPath];

}
以下是fetchCellsToProcess:方法:

-(void)fetchCellsToProcess:(NSIndexPath*)indexPath{
    for (int cellsToProcess = 0; cellsToProcess < 5; cellsToProcess++) {
         //process each cell
         //...
   }
}
-(void)fetchCellsToProcess:(nsindepath*)indepath{
对于(int-cellsToProcess=0;cellsToProcess<5;cellsToProcess++){
//处理每个单元格
//...
}
}

我需要使用indexPath来获取其indexPath.row。然后将5添加到该indexPath.row,并仅处理传入的indexPath.row和indexPath.row+5之间的tweet。我应该使用什么编程逻辑在单元格x->x+5之间循环

您不应该在此处使用
cellforrowatinexpath:
这是表示逻辑的一部分,而您正在处理此处的模型级逻辑


查看您的
cellforrowatinexpath:
方法,查看单元格标签的文本来自何处。通常是
NSArray
或其他集合。您的
didSelectRowAtIndexPath:
方法应该直接转到同一个集合,并从那里获取信息。

没有直接的方法来实现这一点,正如DasLinkedLight所提到的
但有一项工作对我来说很有用。
请遵循以下方法:
在自定义单元格中创建自定义按钮
创建自定义单元类并放置按钮(将类型更改为自定义)进行必要的连接自定义单元类
从实现此逻辑的类中的按钮创建并连接名为“actionSelectedCell”的操作方法,如下所示。
和cellforrowatinexpath cell.customButton.text=数组或字典中的数据


这是让我困惑的“简单逻辑”。事实证明,事情并非如此简单。我必须从所选行中计算5个单元格indexath.rows并获取它们的数据。我在想,因为for循环可能不是最好的选择。嘿,谁否决了我的问题,为什么?
- (IBAction)actionSelectedCell:(UIButton *)sender {

// below code for getting selected cell row and its section

UIView *view = sender.superview;
while (view && ![view isKindOfClass:[UITableViewCell self]]) view = view.superview;

UITableViewCell *cell = (UITableViewCell *)view;
indexPathForSelectedCell = [self.tableViewListViewVC indexPathForCell:cell];
NSLog(@"cell is in section %d, row %d", indexPathForSelectedCell.section, indexPathForSelectedCell.row);// so now you are getting indexpath for selected cell

 // now you can create simple loop logic to get required data and do whatever you like post it to something or store it for any other use

NSString *strFifthCellContent = [NSString stringWithFormat:@"%@",[dataArray ObjectAtIndex:indexPathForSelectedCell.row+5]]; // in this way you can get data from any cell




}