开发者

In Three20, can I not use custom table cells in a searchViewController?

开发者 https://www.devze.com 2023-03-07 07:02 出处:网络
I\'m implementing a TTTableViewController with a searchViewController part, and I\'m running into issues when displaying the results of the search in the search\'s TableView.

I'm implementing a TTTableViewController with a searchViewController part, and I'm running into issues when displaying the results of the search in the search's TableView.

If I add TTTableTextItems to the datasource items property, it works fine, but if I try to add a TTTableCaptionItem or a TTTableImageItem or any custom cell I've created, the rendering is messed up.

Can anyone confirm that it's possible to use custom table cells in a searchViewController and perhaps point me in the right direction for how to make it work?

I've attached 3 screen shot to show what's working and what's not working.

No. 1: Works with this code:

[self.items addObject:[TTTableTextItem itemWithText:[item objectForKey:@"title"]]];

In Three20, can I not use custom table cells in a searchViewController?

No 2. Breaks the layout with this code:

[self.items addObject:[TTTableCaptionItem itemWithText:[item objectForKey:@"title"]
                                               caption:[item objectForKey:@"excerpt"]]];

In Three20, can I not use custom table cells in a searchViewController?

No. 3 Also breaks the layout with this code:

[self.items addObject:[TTTableImageItem itemWithText:[item objectForKey:@"title"]
               开发者_Python百科                             imageURL:[item objectForKey:@"thumbnail"]]];

In Three20, can I not use custom table cells in a searchViewController?


OK, I figured it out. The key is setting the the variableHeightRows property to YES in the TTTableViewController that you're using as the search controller. Below is the code I've used.

TTTableViewController* searchController = [[[TTTableViewController alloc] init] autorelease];
searchController.dataSource = [[[MagazineSearchDataSource alloc] init] autorelease];   
searchController.variableHeightRows = YES;

self.searchViewController = searchController;
self.tableView.tableHeaderView = _searchController.searchBar;
0

精彩评论

暂无评论...
验证码 换一张
取 消