Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 三个20 TTTableViewController和searchViewController_Iphone_Ios_Three20 - Fatal编程技术网

Iphone 三个20 TTTableViewController和searchViewController

Iphone 三个20 TTTableViewController和searchViewController,iphone,ios,three20,Iphone,Ios,Three20,我试图根据TTCatalog中的示例实现将收件人添加到TTMessageController。 在我进入搜索控制器之前,一切都很正常-我可以搜索并获得结果,但当我选择项目时,什么都不会发生。我试图设置代理,但没有成功 - (void)loadView { [super loadView]; TTTableViewController* searchController = [[TTTableViewController alloc] init]; searchContr

我试图根据TTCatalog中的示例实现将收件人添加到TTMessageController。 在我进入搜索控制器之前,一切都很正常-我可以搜索并获得结果,但当我选择项目时,什么都不会发生。我试图设置代理,但没有成功

- (void)loadView {
    [super loadView];

    TTTableViewController* searchController = [[TTTableViewController alloc] init];
    searchController.dataSource = [[FriendsDataSource alloc] initWithApi:self.appDelegate.api];
    searchController.variableHeightRows=YES;
    self.searchViewController = searchController;
    self.tableView.tableHeaderView = _searchController.searchBar;
}

在TTCatalog中,搜索中的项目有一个指向google的URL——这没有多大帮助;)

好的,我找到了答案:)

上面的代码缺少一行。我有一种感觉,我应该设置代表,但不知道在哪里:

- (void)loadView {
    [super loadView];

    TTTableViewController* searchController = [[TTTableViewController alloc] init];
    searchController.dataSource = [[FriendsDataSource alloc] initWithApi:self.appDelegate.api];
    self.searchViewController = searchController;
    _searchController.searchResultsTableView.delegate=self;
    self.tableView.tableHeaderView = _searchController.searchBar;
}
然后,添加以下内容以允许可变高度:

- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath {
    id<TTTableViewDataSource> dataSource = (id<TTTableViewDataSource>)tableView.dataSource;

    id object = [dataSource tableView:tableView objectForRowAtIndexPath:indexPath];
    Class cls = [dataSource tableView:tableView cellClassForObject:object];
    return [cls tableView:tableView rowHeightForObject:object];
}

我只是想发布完全相同的问题!我想您已经实现了
-(void)didSelectObject:(id)object atIndexPath:(nsindepath*)indexath{[\u delegate searchTestController:self didSelectObject:object];}
对吧?我缺少委托集了……我知道您在那里做了什么。设置
UITableViewDelegate
,这是一个很好的方法。然而,我期待着Three20会更聪明一点,并以某种方式为你做到这一点。不管怎样,你解决了我的问题。谢谢!
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    TTTableImageItemCell *cell = (TTTableImageItemCell *) [tableView cellForRowAtIndexPath:indexPath];
    TTTableImageItem *object = [cell object];
    [_delegate MessageAddRecipient:self didSelectObject:object];
}