-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath
{
Static nsstring *[email protected] "Reporttableviewcell";
Reporttableviewcell * cell = [TableView dequeuereusablecellwithidentifier:identifier];
if (!cell)
{
cell= [[[NSBundle mainbundle]loadnibnamed:@ "Reporttableviewcell" Owner:nil Options:nil] firstObject];
Cell.selectionstyle=uitableviewcellselectionstylenone;
}
Cell. Contentlabel.text=[self.tabledata ObjectAtIndex:indexPath.row];
if ([[Nsuserdefaults standarduserdefaults]valueforkey:@ "Selectedrowreport"]==[nsnumber NumberWithInteger: Indexpath.row])
{
Cell.accessorytype = Uitableviewcellaccessorycheckmark;
}
Else
{
Cell.accessorytype = Uitableviewcellaccessorynone;
}
return cell;
}
When a row is selected
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{
Jump to a detailed view controller
[[Nsuserdefaults Standarduserdefaults]setvalue:[nsnumber NumberWithInteger:indexPath.row] forkey:@ " Selectedrowreport "];
[Self.tableview Reloaddata];
Uncheck rows
[TableView Deselectrowatindexpath:indexpath Animated:yes];
}
By default, the 1th one is added to the viewdidload.
[[Nsuserdefaults Standarduserdefaults]setvalue:[nsnumber numberwithinteger:0] forkey:@ "SelectedRowReport"];
UITableView Setting the cell check status (right with checkmark)