@property
(
nonatomic
,
strong
)
NSIndexPath
*selectedIndexPath;
{
static NSString *CellIdentifier = @"YFCELLEDITDOCACADEMIC" ;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier :CellIdentifier];
if (cell == nil ) {
cell = [[ UITableViewCell alloc ] initWithStyle : UITableViewCellStyleDefault reuseIdentifier :CellIdentifier];
}
//config the cell
cell. textLabel . text =[ academicArray [indexPath. row ] objectForKey : @"Typename" ];
cell. tag =[[ academicArray [indexPath. row ] objectForKey : @"Typeid" ] intValue ];
if ([ self . selectedIndexPath isEqual :indexPath])
cell. accessoryType = UITableViewCellAccessoryCheckmark ;
else
cell. accessoryType = UITableViewCellAccessoryNone ;
return cell;
}
-( void )tableView:( UITableView *)tableView didSelectRowAtIndexPath:( NSIndexPath *)indexPath{
if ( self . selectedIndexPath ) {
UITableViewCell *cell = [tableView cellForRowAtIndexPath : self . selectedIndexPath ];
cell. accessoryType = UITableViewCellAccessoryNone ;
}
UITableViewCell *cell = [tableView cellForRowAtIndexPath :indexPath];
cell. accessoryType = UITableViewCellAccessoryCheckmark ;
self . selectedIndexPath = indexPath;
[tableView deselectRowAtIndexPath :indexPath animated : YES ];
}