- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于我的应用程序,我需要多次推送同一个 TableViewController。当用户点击 didSelect 时,我需要在导航堆栈中推送相同的 Controller 。
我的应用程序是文件管理器应用程序,它连接到 ftp 服务器并向用户显示里面的内容。但是文件夹中可能有包含更多文件夹(无限)的文件夹。
为此,我无法在 Storyboard 中创建大量 TableViewController,当我尝试使用以下方法将同一个 Controller 插入导航堆栈时:
navigationController?.pushViewController(self, animated: true)
我收到错误消息说我无法在导航堆栈中推送相同的 Controller 。所以我创建了我的 Controller 的新实例并尝试像这样推送:
让 newMyTableVC = MyTableVC()
navigationController?.pushViewController(newMyTableVC, animated: true)
但是有了这个我也得到错误说:
'unable to dequeue a cell with identifier FolderCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
所以我从这个错误中了解到我的第一个 TableViewController 使用我的单元格标识符并且它在内存中。当我尝试传递具有相同单元格标识符的 TableViewController 的新实例时,它崩溃了,因为单元格已经存在且具有相同的标识符。(我可能错了)。
If i am on right track doing this with approach at the above {
How do i reuse cells with dynamic identifier and provide data to them.
} else {
How do i accomplish what i want?
}
感谢您的宝贵时间。
最佳答案
当您像这样创建一个新实例时:
let newMyTableVC = MyTableVC()
它完全独立于 Storyboard。重要的是,它因此对 Storyboard中定义的原型(prototype)单元一无所知。因此,错误的相关部分是“...或在 Storyboard 中连接原型(prototype)单元”。
为避免此问题,请在 Storyboard中为您的 TableView Controller 设置一个标识符,然后使用:
let newMyTableVC = self.storyboard!.instantiateViewControllerWithIdentifier("identifier") as! MyTableVC
关于ios - 多次将同一个 TableViewController 插入导航堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39856292/
在我正在处理的当前项目中,我需要在 View 之间传输变量。我成功地将变量从 tableviewcontroller 传输到 UIviewcontroller,如下所示。 if segue.ident
我在将数据从 TableViewController 传递到嵌入 Container View 中的另一个 TableViewController 时遇到问题。当我在 prepareForSegue
我看过但没有找到合理的答案。我有第一个 TableViewController 可以容纳 4 行,当用户点击一行(导航层次结构)时,我想传递给第二个 tableViewController 一个字符串
我有一个正在创建的表单 此表单填充了用户输入的文本字段。回答完所有问题后,会弹出一个按钮进行保存。 我在让此 tableviewcontroller 将数据传递给新的 tableviewcontrol
我有一个带有搜索栏的表格 View 。搜索栏返回用户名包含搜索栏中文本的 PFUser。该部分工作正常,并且获取的用户显示在 TableView 中。当用户点击表格 View 单元格时,我想转到另一个
我正在开发一个基于日期的应用程序。我正在尝试获取从一个 TableViewController 传递到另一个 TableViewController 的信息。 这是一个基于通知的应用程序,可以提醒用户
我正在尝试从一个 TableViewController 中选择一个详细信息披露按钮(或一行)并转到另一个 TableViewController,而不将任何数据从第一个 TableViewContr
我正在尝试通过委托(delegate)将 TableView Controller B 中的图标和名称传递给 View Controller A。 为了简单起见,向用户展示了 ViewControll
我一直在尝试将一些数据(String)从TableViewController传递到嵌入在容器。 在 MainTableViewController 中我有以下代码: let vc = SecondT
这个问题已经有答案了: Passing data between view controllers (44 个回答) 已关闭 6 年前。 我有一个UITableViewController在列表中显示
据我了解,我无法使用 socket 连接将单元格中的按钮连接到我的 TableViewController。 不过,我可以使用操作连接将单元格中的按钮连接到我的 TableView。这是我巨大问题的根
我一直在努力切换 viewController。 我得到了以下 Storyboard: 左上角的 VC 是登录 VC,它通过模态 Segue 将 View 推送到 MainViewController
我有一个嵌入在 UINavigationController 中的 UITableView。我在 Storyboard中设置了一个 rightBarButtonItem 。如果我以正常方式继续,一切都
当detailText大于3行时,tableViewCell的标题标签总是被切掉,而detailText仅部分显示。我已设置 rowHeight 和 estimatedRowHeight,但结果保持不
我有以下问题: 我有一个应用程序,它使用两个 tableViewController。第一个 TableViewController 列表 struct Task{ let type: Stri
class SelectionBoxViewController: UITableViewController,UISearchBarDelegate { var searchbar = UI
我是 swift 的初学者,但我在 HTML、CSS 和一些 Java 方面确实有不错的背景。我创建这个帐户实际上只是为了问这个问题,所以我会开门见山。 我真的很喜欢 swift,但我真的花了一周的时
有没有办法将statusbar lightcontent颜色设置为UITableViewController? 好像没有这个功能 override open var preferredStatusBa
场景 |第一个单元 | |第二个细胞||开关 || | |第三单元 ||文本字段 | 我创建了一个包含三个不同类的动态表格 View :SecondTableCell(其中有一个开关的导出)和Thir
我正在将图像从 RESTApi 加载到 Netflix(例如 ScrollView)中。 func collectionView(_ collectionView: UICollectionView,
我是一名优秀的程序员,十分优秀!