开发者

Add a button in a UITableViewCell when UISearchBar has no results (like Mail app)

I want to mimic the behavior of the Mail app when no results are 开发者_JAVA技巧found from the UISearchBar, and show a cell with a link to call a method. I can't figure out (or find anywhere) how to do so.

The closest I think I've come is the following (which I've added into my code)

if ([self.keys count] == 0){
    [self.tableView beginUpdates];
    [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationBottom];
    [self.tableView endUpdates];
}
[tableView reloadData];


I believe something like that should work but your uiTableViews:rowsInSection: and such methods still need to return the right count, and cellForRowAtIndexPath needs to do the right thing too. Since it has to do that anyway, you might just want to set some flag and call reloadData on the table view. (In fact, without the cellForRowAtIndexPath the reloadData is probably just clearing the table again.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜