ios - 注销按钮创建后退按钮

标签 ios swift uitableview button uibutton

我在我的 UITableViewController 中创建了一个按钮作为 Left Bar Button Item,用于注销当前用户并继续登录 ViewController

问题是点击它会在登录 ViewController 上创建一个后退按钮,用户可以返回到上一个 View 。

最佳答案

通常应用程序流程的工作方式就像我们将 loginViewController 设置为我们应用程序的 rootviewcontroller 并根据我们的应用程序流程推送一个 nextViewController及其需要。但在您的情况下,您在注销时再次推送 loginViewController 而不是您需要 popToRootViewControllerAnimated 代码

因此,在您的注销按钮 clickEvnet 上使用以下代码:

[self.navigationController popToRootViewControllerAnimated:YES];

我不建议使用隐藏 BackBarButton 和做任何其他你可以简单地通过放置 popToRootViewControllerAnimated

如果您正在快速编写代码,您可以使用以下代码:

 self.navigationController?.popToRootViewControllerAnimated(true)

更新 我只是为你创建一个例子。您可以从以下网址下载:

https://github.com/nitingohel/swiftSeque

它的输出如下:

enter image description here

关于ios - 注销按钮创建后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37187066/

相关文章:

ios - 我们可以访问用户在 iOS 中设置的自动锁定设置吗?

ios - 如何在 iOS iCarousel 中正确使用 iCarouselOptions?

ios - UITableViewCell 数据未显示在 UITableViewController 中

iOS swift : Static Cell

ios - 如何在 Mapkit Swift 中随机放置注释

ios - 简单的字符串加解密算法

ios - CABasicAnimation 如何获取当前的旋转角度

swift - 如何检测 swift 应用程序何时从后台变为前台?

ios - 我的导航栏中的图像不会显示 - 在 Swift 中

iOS Swift,使用标签更新 tableview CellForRow 之外的 UITableView 自定义单元格标签