ios UITableViewController 元素与孩子 [英] ios UITableViewController elements with childs

查看:19
本文介绍了ios UITableViewController 元素与孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望生成一个导航列表.

I wish to generate a navigation-list.

我有一个 UITableViewController,如果单击一个单元格,则显示在 UITabeViewController 中的单元格的子单元格应该出现,并且应该出现一个后退按钮.

I Have a UITableViewController and i would that if a cell is clicked the child's of the cell where displayed in the UITabeViewController and a back-button should appear.

目前为了测试我做了/做了这个:

Currently for tests i do/did this:

var anz = 10
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return anz
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if anz<10 {
        navigationController?.popToRootViewControllerAnimated(true)
    }
    anz = 5
    self.tableView.reloadData()
}

但是没有后退按钮(当然).

But there is no back-button (of course).

所以它应该是这样的:

谢谢.

推荐答案

要在导航栏中有后退按钮,您需要按下控制器.

To have back button in navigation bar you need to push your controller.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if anz<10 {
       navigationController?.popViewControllerAnimated(true)
    }
    anz = 5
      let vc = YourViewController with custom INIT where you can pass anz
     navigationController?.pushViewController(vc, animated: true)
}

这里 YourViewController 是您当前的视图控制器,带有您在图片中显示的表格视图.

Here YourViewController is your current view controller with table view you are showing in picture.

这篇关于ios UITableViewController 元素与孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆