ios - 从 Swift 中的 UITableViewController 转出后,我的 ViewController 中缺少后退按钮

标签 ios xcode swift uitableview ios9

在我的项目中,我有一些 View Controller ,并且使用 UINavigationController

当我从 UIViewControllerUITableViewController 制作序列时,我会自动添加“后退”按钮,但是当我从 UITableViewController 制作序列到UIContentViewController 点击了一个单元格,我在 UIContentViewController 中没有“后退”按钮。

我的应用程序的计划在这里 plan of aplication and kind of segue

UITableViewController 中的 segue 看起来像这样:

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

    let CV =   self.storyboard?.instantiateViewControllerWithIdentifier("ContentViewController") as! ContentViewController

    let tnumber = tableView.indexPathForSelectedRow?.item

    CV.titleContent = daneOWpisach?[tnumber!]["title"]
    CV.webContent = daneOWpisach?[tnumber!]["description"]
    CV.category = category

self.presentViewController(CV, animated: true, completion: nil)
}

如果我想在 UIContentViewController 中自动添加后退按钮,我该怎么办?

最佳答案

在您的代码中,您将在单元格选择上呈现 View Controller ......!仅当您执行推送而不是呈现 View 时,后退按钮才会显示。

在上图中,我看到的是您已经从 UITableViewController 转到 UIContentViewController。选择 Segue 并转到属性检查器,给出 Segue 的标识符。

在单元格选择上使用您指定的标识符执行 segue 操作

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

self.performSegueWithIdentifier("Your Segue name", sender: sender)
}

如果您想将数据传递到目标 View Controller ,请按如下操作..

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
        if segue.identifier == "Your Segue name" {
          let CV =   segue.destinationViewController as! ContentViewController
           let tnumber = tableView.indexPathForSelectedRow?.item

        CV.titleContent = daneOWpisach?[tnumber!]["title"]
        CV.webContent = daneOWpisach?[tnumber!]["description"]
        CV.category = category 
        }
    }

希望这对你有帮助

关于ios - 从 Swift 中的 UITableViewController 转出后,我的 ViewController 中缺少后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34342621/

相关文章:

swift - CocoaLumberjack Swift 框架

swift - ios13 中 UITextfield 的 PlaceholderColor 未设置为 PlaceHolderLabel

ios - 突出显示动态创建的 UIButtons?

ios - 如何从自定义单元格保存 UILabel 以便每次打开应用程序时它都会显示最新更改?

ios - 按下以编程方式创建的新按钮时如何继续?

ios - 如何在 Swift 中加载初始 View Controller ?

iphone - 在模态转场之后移除最后一个 UIViewController

ios - Swift 中从不同 URL 解析多个 JSON

ios - 钛给出错误:指定的配置文件无效或类型错误

iphone - 更新现有的 iOS 应用程序