2012-01-04 5 views
2

TTCatalogの例に基づいて、TTMessageControllerに受信者を追加する実装を試みています。 検索コントローラに入るまではすべて正常に動作します。検索して結果を得ることができますが、アイテムを選択すると何も起こりません。私はデリゲートを設定しようとしましたが、何も動作しません。 TTCatalogでThree20 TTTableViewControllerとsearchViewController

- (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; 
} 

、検索の項目はGoogleに指示するURLを持っている - それは非常に有用ではありません。)

+0

私はまったく同じ質問を投稿しようとしていました。 – Dimme

+0

あなたは既に ' - (void)didSelectObject:(id)オブジェクトをatIndexPath:(NSIndexPath *)indexPath { [_delegate searchTestController:self didSelectObject:object]; }「そうですか? – Dimme

+0

私はデリゲートセットがありませんでした.... –

答えて

2

OK、私は答えを見つけた:)

1行から欠落していました上のコード。私は、デリゲートを設定する必要が気持ちを持っていましたが、どこ知りませんでした:

- (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) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    TTTableImageItemCell *cell = (TTTableImageItemCell *) [tableView cellForRowAtIndexPath:indexPath]; 
    TTTableImageItem *object = [cell object]; 
    [_delegate MessageAddRecipient:self didSelectObject:object]; 
} 
+0

私はあなたが何をしたかを見ます。良い方法は 'UITableViewDelegate'を設定することです。しかし、私はThree20がもっと知的になり、何とかあなたのためにこれをやることを期待していました。とにかく、あなたは私の問題を解決しました。どうもありがとう! – Dimme

関連する問題