gpt4 book ai didi

swift - 当用户使用 swreveal Controller 登录或注销时,我需要重新加载 TableView 菜单吗?

转载 作者:行者123 更新时间:2023-11-30 10:10:21 25 4
gpt4 key购买 nike

我的表格 View 菜单上有一个“登录”按钮。当用户触摸时,它会显示我需要的登录 View 。当用户成功登录时,重新加载表格 View 以隐藏“登录”按钮并显示“帐户”按钮,反之亦然

最佳答案

我不明白你用按钮做什么。我和我的团队通常将表格单元格用作菜单项。就像这个例子

enter image description here

enter image description here

  • 我定义了一个菜单项数组

    var menuItems = ["登录", "我的 abc", "我的 def"]

  • 还有登录功能的代码,删除“登录”并添加“我的帐户”。在我的简单示例中,我使用 didSelectRowAtIndex 并选中“登录”菜单

      override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    // sign in item
    if indexPath.row == 0 && menuItems[0] == "Sign in" {

    let alert = UIAlertController(title: "Signing in", message: "Press OK to sign in", preferredStyle: .Alert)

    alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))

    alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in

    self.menuItems.removeAtIndex(0)
    self.menuItems.insert("My Account", atIndex: 0)

    tableView.reloadData()
    }))

    presentViewController(alert, animated: true, completion: nil)

    }
    }

希望这有帮助。

关于swift - 当用户使用 swreveal Controller 登录或注销时,我需要重新加载 TableView 菜单吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33291659/

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