asynchronous - Tell user in ios with a Tableview that the most recent call to server did not get any data -
i making call (with afnetworking) server. when data, put array , call refresh screen. far, good. i'm not sure how asynchronous calls server tell user (in, say, cell) there no data display. , when there data display, rid of "no data display" cells.
using ios 6.1, support ios 5.
if understand correctly, you'd way of showing 'no data display' message if there no results, , replace when data available.
my approach display loading indicator (overlaid on table view) user when start loading content (i.e. when first making call server). can have flag on controller tracks whether you're loading data - set yes when start loading, , no when loading completes. while loading, can not display cells in table (assuming have other display show user it's loading). e.g.
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (isloading) return 0; //don't display cells while loading if (modelarray.count == 0) return 1; //1 row cell indicating there's no data return modelarray.count; //1 row each entry in array }
when server returns data, remove loading indicator , refresh table view data.
when no data returned, presumably model array empty. check case in tableview:cellforrowatindexpath:
in uitableviewdatasource, , if array empty, return cell message indicating there's no data, e.g.
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if (modelarray.count == 0) { return noresultsmessagecell; } else { <normal cell dequeueing code> } }
Comments
Post a Comment