In my app, I used xml parser.Well, using xml parsing i set text of cell of tableview and onclick of cell particular image visible for user which is also coming from xml parsing.these all things are done.but,
I want to implement Badge icon to the uitableviewcell whenever new feed available in xml link. and onclick of that cell the badge should be removed from that cell.
My problem is as follows:- I tried tutorials for custom badge overay or customization of label and add that开发者_如何学编程 label in uitableviewcell's contentview.But you all can suggest me whatever way u tried but in all these i cant find updating when new feed available.
And if above is more complicated yours can help me as this way:-(forget the xmlparsing)initially take all the cell has badge icon and on click of 1 particular cell how can i just remove the badge of that cell.
thanx in advance for any help!
Assuming that you want to display the unread items. You can do this by maintaining an mutable array of unread times and updating your customized label based on the row in tableView:cellForRowAtIndexPath:
. Obviously, cells with zero unread items would not show the label.
You can handle the click by becoming the delegate of the table view and responding to tableView:didSelectRowAtIndexPath:
like this –
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
[self.unreadItems replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithInt:0]];
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}
As for the feed having new data, you will have to check periodically and if new data is available, download them in the background and update the unread counts appropriately.
精彩评论