gpt4 book ai didi

ios - 带有 SKSTableViewCell 选择问题的 UITableView

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:02:08 25 4
gpt4 key购买 nike

我正在使用 SKSTableView一切正常。我遇到了一个问题,找不到解决方法。

当我展开第一个和第二个单元格,然后从第一个展开的子行单元格中进行选择时,我得到了第二个行名称和第一个选定的子行名称。我应该得到的是第一个子行名称的名字。我该如何解决这个问题?

- (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];
}

关于ios - 带有 SKSTableViewCell 选择问题的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28632266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com