plist 和 TableView
休斯顿,我遇到了一个问题,我已经解决了 5 天但无法解决它:所以,我正在开发一个具有 tabBarController
的应用程序。在第一个选项卡上,有一个 tableViewController
,其中包含一些对象。当我按下单元格
时,我会转到其中有一个按钮的表单。当我按下此按钮时,它会保存顶部的 navigationBar
标题(因此,它会保存您按下的单元格的标题)。然后,当我转到另一个(第二个)选项卡时,我们可以看到其中包含 tableView
的视图。我期望在单元格中看到的是第一个选项卡中导航栏(或单元格)的标题。但相反,我在此 tableView 中看到第一个 tableView 中的所有对象,但没有看到我保存的对象。
这是我的代码: https://gist.github.com/1501328
再说一次:第一个选项卡有一个表视图控制器。当我按下随机单元格时,我会移动到另一个带有按钮的视图。当我按下按钮时,我保存了导航栏的标题,因此它与我点击的单元格名称相同。当我移动到第二个选项卡时,我可以看到其中包含 tableview 的视图,并且我想在单元格中查看保存的标题,但我看到第一个选项卡 tableView 中的所有对象。
我绝望了,请帮助我 stackoverflow 社区! ! !
Houston, I have a problem, which I am working on for 5 days and cant fix it: So, I am working on an app which has tabBarController
. On the first tab, there is a tableViewController
with some objects in it. And when I press a cell
, I turn to form with a button in it. And when I press this button, it saves the title of navigationBar
which is on the top (so, it saves a title of cell which you pressed). Then, when I turn to another (second) tab, we can see a view with tableView
in it. And what I expecting to see in a cell is that title of navBar(or cell) from the first tab. BUT instead, I see in this tableView ALL the objects from the first tableView, but not that one I saved.
Here is my code: https://gist.github.com/1501328
So again: First tab has a tableViewController. When I press a random cell, I move to another view with button on it. When I press the button I save the title of navBar, so its the same as cell name which I tapped. And when I move to second tab, I can see a view with tableview in it and I want to see a saved title in a cell but I see ALL the Objects from the first tab tableView.
I despair, please, help me stackoverflow community ! ! !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在两个表视图中获得相同内容的原因很可能是因为它们共享相同的
dataSource
。如果同一个对象要作为两个(或多个)表视图的数据源,则必须在委托和数据源方法中进行区分(使用
tableView
参数)。检查标题信息是否存储在正确的位置,然后仔细检查委托和数据源方法,并确保它们在返回行数和单元格数时在表视图之间产生差异。
如果不是,则为显示错误值的表视图设置适当的
delegate
和dataSource
。查看代码时,只有
Favorites
符合委托和数据源协议,该对象是两个表的委托和数据源吗?这些方法中没有任何内容可以解决差异......The reason why you got the same content in the two table views is most probably because they share the same
dataSource
.If the same object is meant to be the dataSource of two (or more) table views, then you must make the difference in delegate and datasource methods (using the
tableView
parameter).Check if the title information is stored at the right place, and then double check delegate and datasource methods and ensure they make the difference between the table views when returning number of rows and cells.
If not, then set the appropriate
delegate
anddataSource
for the table views that displays wrong values.When looking at the code, only
Favorites
is conforming to delegate and datasource protocols, is this object the delegate and datasource for both tables ? Nothing in these methods take care of the difference...