I have a TTTableView (_commentsItem) embedded in another TTTableView like so:
self.dataSource = [DetailItemDataSource dataSourceWithObjects:
@"",
self.imageItem,
@"",
findItem,
@"",
_descriptionItem,
@"",
self.shareItem,
self.editItem,
@"",
_commentsItem,
@"",
_addCommentButtonItem,
nil];
When _commentsItem has rows, everything works great. I can even add rows to the table in _commentsItem, call [.. refresh], and the enclosing table will adjust itself accordingly.
The problem occurs when _commentsItem is empty. Normally, you'd expect to get a TTErrorView overlaying the whole screen, but I get nothing (actually, I don't even want it to overlay the whole screen, I'd just like to get the "emptyTitle" to show up.
I think the problem is in TTTableView's "ShowEmpty" which is creating another view to contain the TTErrorView, which the enclosing table knows nothing about:
- (void)showEmpty:(BOOL)show {
if (show) {
NSString* title = [_dataSource titleForEmpty];
NSString* subtitle = [_dataSource subtitleForEmpty];
UIImage* image = [_dataSource imageForEmpty];
if (title.length || subtitle.length || image) {
TTErrorView* errorView = [[[TTErrorView alloc] initWithTitle:title
subtitle:subtitle
image:image] autorelease];
errorView.backgroundColor = _tableView.backgroundColor;
self.emptyView = errorView;
} else {
self.emptyView = nil;
}
_tableView.dataSource = nil;
[_tableView reloadData];
} else {
self.emptyView = nil;
}
}
I suspect that showEmpty isn't really intended to work correctly when it's TTTableView is embedded in another TTTableView, but then the question becomes how to do this. The enclosing table expects _commentsItem to be a TTTableViewItem, so I can't just swap _commentsItem's view for, say a UILabel.
So the question is: When you have a TTTableView embedded in another TTTableView, what is the best way to display a "Table Empty" state for the embedded table?
Thanks!.