0

I am having a lot of trouble working with these Tables. I am porting an iPhone app over to the iPad. I have two UITableViews on the iPad, each with their own Controller. On the iPhone, these tables each have their own screen. When you get to the first table (a list of categories), you select a row, and then a push segue brings you to the second table (all of the items that pertain to that specific category). However, on the iPad, I cannot get the second table to update when a cell is selected from the first table. I cannot reloadData because I am having trouble telling the 2nd table what category was picked from the 1st table.

Some good news: Both tables show up on the root view controller (UIViewController). Table 1 shows all of it's categories, and table 2 shows all of the items from the first category from viewDidLoad (I programmed it to display the first set of items to ensure that it was at least working).

So my question is the line in the title, how do I change the content of the 2nd table based on which cell is selected from the first?

EDIT: I have more than just 2 tables on this one iPad view. I tried to post an image, but can't yet.. There are 4 table views, a custom Banner ad imageview, and some labels.

4

1 回答 1

2

你描述的是一个标准的主从界面。我猜细节视图控制器在 .h 文件中定义了一个属性,您可以在其中设置新的“细节项”。如果没有,您需要添加一个(并且您当前必须在 init 方法中添加一个或其他内容)。

为该属性实现 setter 方法,更新详细信息项,然后reloadData.

这样,您只需更新现有的视图控制器,而不是每次都尝试创建一个新的。

我建议您在 Xcode 中创建一个新的 iPad(或通用)项目,选择主从项目模板并查看它包含的代码。

于 2013-06-06T18:28:37.283 回答