gpt4 book ai didi

ios - 单击可扩展 TableView 中的子菜单时,我们可以导航到新 View 吗?

转载 作者:行者123 更新时间:2023-11-28 16:07:24 26 4
gpt4 key购买 nike

我有一个包含许多按钮的 HRMS 屏幕。我想根据更多功能对每个按钮进行分类,例如

考勤-> 考勤标记 考勤登记

离开-> 请假申请 离开 OD 授权 离开OD批准

其他-> 假日 list 留下余额

现在我的屏幕看起来像这样HRMS

我正在尝试实现可扩展 ListView 。逻辑很简单,当单击子菜单时,我想转到与其关联的特定 View Controller 。虽然我知道如何使用简单的 TableView 来做到这一点

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!)

我不知道如何在使用可扩展 TableView 时实现它。我用谷歌搜索了同样的内容,但找不到具体的解决方案。

最佳答案

你可以使用

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!)
{
if (indexPath.section == 0)
{
if (indexPath.row == 0)
{
/*The first row of the first section was tapped.
Put code here that you would like to execute when the
first row of the first section is tapped*/
}
if (indexPath.row == 1)
{
/*The second row of the first section was tapped.
Put code here that you would like to execute when the
second row of the first section is tapped*/
}
}

if (indexPath.section == 1)
{
if (indexPath.row == 0)
{
/*The first row of the second section was tapped.
Put code here that you would like to execute when the
first row of the second section is tapped*/
}
if (indexPath.row == 1)
{
/*The second row of the second section was tapped.
Put code here that you would like to execute when the
second row of the second section is tapped*/
}
}
}

与普通表格 View 相同的可扩展表格 View 。只需将您的代码放入上述方法中,为所需的 tableView 行调用新的 viewController。

要记住的一件事是,当您使用多个部分时(如果您使用的是可扩展的 tableView,将会是这样),那么每个部分的行索引从零开始。

例如在你的 tableView 中有三个部分,每个部分三行,它们的索引是这样的

  • 第 0 节

    • 第 0 行
    • 第 1 行
    • 第 2 行
  • 第 1 节

    • 第 0 行
    • 第 1 行
    • 第 2 行
  • 第 2 节

    • 第 0 行
    • 第 1 行
    • 第 2 行

因此您需要在 didSelectRowAtIndexPath 方法中检查部分和行

关于ios - 单击可扩展 TableView 中的子菜单时,我们可以导航到新 View 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40080363/

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