2011-07-18 5 views
0

検索ビューコントローラで動作するようにvariableHeightRowsを取得できませんでした。searchViewControllerのThree20:variableHeightRows

TTTableViewController* searchController = [[TTTableViewController alloc] init]; 

searchController.dataSource = [[[SomeDataSource alloc] init] autorelease]; 
searchController.variableHeightRows = YES; // this doesn't affect the table 

self.searchViewController = searchController; 
[searchController release]; 
self.tableView.tableHeaderView = _searchController.searchBar; 
_searchController.pausesBeforeSearching = YES; 
[_searchController setSearchResultsDelegate:self]; 

デフォルトの高さの行が常に表示されます。同じデータソースを使用している私の通常のテーブルビューでは、行の高さは私が提供したカスタムのものに設定されています(+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object)が、特に検索コントローラにはありません。

私は間違っていますか?深い調査の後

答えて

1

...

私が作成するTTTableViewVarHeightDelegateデリゲートを防止何か、そのため、カスタムheightForRowAtIndexPathが呼び出されなかった、同じクラス([_searchController setSearchResultsDelegate:self];)に検索コントローラのデリゲートを設定します。 (TTTableViewVarHeightDelegateのソース)TTTableViewControllerクラスに

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

をし、それが働いた:私は付け加えました。