带有 SKSTableViewCell 选择问题的 UITableView
UITableView with SKSTableViewCell Selection issue
我正在使用 SKSTableView,一切正常。我遇到了一个问题,找不到解决方法。
当我展开第一个和第二个单元格,然后从第一个展开的子行单元格 select 时,我得到第二个行名称和第一个 selected 子行名称。我应该得到的是第一个子行名称的名字。我该如何解决这个问题?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SKSTableViewCell *cell = (SKSTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
UITableViewCell *selectedCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
if ([cell respondsToSelector:@selector(isExpandable)]){
if ([cell isExpandable])
{
NSLog(@"SELECTED Row %@", _selectedCellTxt);
}
else{
_selectedCellTxt = selectedCell.textLabel.text
[self performSegueWithIdentifier:@"123" sender:self];
}
}
- (void)tableView:(SKSTableView *)tableView didSelectSubRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *selectedCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedSubCellTxt = selectedCell.textLabel.text;
NSLog(@"SELECTED Sub Row %@", _selectedSubCellTxt);
[self performSegueWithIdentifier:@"123" sender:self];
}
这就是我通过调用 didSelectSubRowAtIndexPath
中的 cellForRowAtIndexPath
来解决我的问题的方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SKSTableViewCell *cell = (SKSTableViewCell *)[self tableView:_tableView cellForRowAtIndexPath:indexPath];
UITableViewCell *selectedCell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
}
- (void)tableView:(SKSTableView *)tableView didSelectSubRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *selectedSubCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedSubCellTxt = selectedSubCell.textLabel.text;
UITableViewCell *selectedCell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
[self performSegueWithIdentifier:@"123" sender:self];
}
我正在使用 SKSTableView,一切正常。我遇到了一个问题,找不到解决方法。
当我展开第一个和第二个单元格,然后从第一个展开的子行单元格 select 时,我得到第二个行名称和第一个 selected 子行名称。我应该得到的是第一个子行名称的名字。我该如何解决这个问题?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SKSTableViewCell *cell = (SKSTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
UITableViewCell *selectedCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
if ([cell respondsToSelector:@selector(isExpandable)]){
if ([cell isExpandable])
{
NSLog(@"SELECTED Row %@", _selectedCellTxt);
}
else{
_selectedCellTxt = selectedCell.textLabel.text
[self performSegueWithIdentifier:@"123" sender:self];
}
}
- (void)tableView:(SKSTableView *)tableView didSelectSubRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *selectedCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedSubCellTxt = selectedCell.textLabel.text;
NSLog(@"SELECTED Sub Row %@", _selectedSubCellTxt);
[self performSegueWithIdentifier:@"123" sender:self];
}
这就是我通过调用 didSelectSubRowAtIndexPath
中的 cellForRowAtIndexPath
来解决我的问题的方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SKSTableViewCell *cell = (SKSTableViewCell *)[self tableView:_tableView cellForRowAtIndexPath:indexPath];
UITableViewCell *selectedCell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
}
- (void)tableView:(SKSTableView *)tableView didSelectSubRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *selectedSubCell = [self tableView:_tableView cellForSubRowAtIndexPath:indexPath];
_selectedSubCellTxt = selectedSubCell.textLabel.text;
UITableViewCell *selectedCell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
_selectedCellTxt = selectedCell.textLabel.text;
[self performSegueWithIdentifier:@"123" sender:self];
}