tableView属性声明或链接

时间:2012-12-31 10:40:58

标签: iphone xcode cocoa-touch properties tableview

我有一个带有SearchDisplayController和TableView

的View(SearchView)

在.h:

@property (nonatomic, retain) IBOutlet UITableView *tableView;

我将.xib文件中的这个链接到TableView:> see linkages here

然后在cellforrow中:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath


if(listGoal){

    Goal *goalz = nil;

    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        goalz = [self.filteredListContent objectAtIndex:indexPath.row];
        cell.textLabel.text = goalz.goalNaam;
    }
    else
    {

        goalz = [arr objectAtIndex:indexPath.row];
        cell.textLabel.text = goalz.goalNaam;
        cell.detailTextLabel.text = goalz.goalBeschrijving;
    }
}

我测试我是否需要filteredListContent或原始数组,arr。 (因为我使用的是SearchDisplayController) 哪个有效。

另一种方法,

 if (tableView == self.searchDisplayController.searchResultsTableView)

不再有效,所以我尝试使用

self.tableView

但这也不起作用

  (UITableView *)tableView

也不起作用。 我知道我的财产声明或联系有问题,但出了什么问题?

1 个答案:

答案 0 :(得分:1)

您可以通过自定义方法访问搜索视图的一种方法是在获取搜索视图时保留对搜索视图的强大引用。但我不确定它是否适用于多次搜索。

可能你可以设置BOOL变量并在自定义方法中使用它。我认为您无法在自定义方法中访问搜索视图。