I want to handle multiple row selection i.e., not more than 3, from where the data is coming from a service(URL). below is some part of code i have tried, but cannot handle the multiple row selection. Could you spare some time to solve it. TIA
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
static NSString *MyIdentifier = #"tableCell";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *) currentObject;
}
}
}
NSDictionary *thisRow = [self.professionArr objectAtIndex:row];
if(_WSConstProfessionID !=nil && ![_WSConstProfessionID isEqual:#"0"] && ![_WSConstProfessionID isEqual:#""] && _WSConstProfessionSelectedIndex ==row ){
cell .accessoryType=UITableViewCellAccessoryCheckmark;
} else {
cell .accessoryType=UITableViewCellAccessoryNone;
}
cell.lblTitle.text = [thisRow objectForKey:_WSColumnProfessionName];
NSString *str=[thisRow objectForKey:_WSColumnProfessionID];
NSString *stra=_WSConstProfessionID;
if ([str isEqualToString:stra]) {
cell .accessoryType=UITableViewCellAccessoryCheckmark;
cell.highlighted=YES;
} else {
cell .accessoryType=UITableViewCellAccessoryNone;
}
return cell;
}
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSUInteger row = [indexPath row];
NSDictionary *thisRow=[self.professionArr objectAtIndex:row];
NSLog(#"%#",[thisRow description]);
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone){
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
if(_WSConstProfessionID!=nil && ![_WSConstProfessionID isEqual:#"0"] && ![_WSConstProfessionID isEqual:#""] &&_WSConstProfessionSelectedIndex!=row){
UITableViewCell *cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:_WSConstProfessionSelectedIndex inSection:0]];
if (cell != nil){
cell .accessoryType=UITableViewCellAccessoryNone;
}
}
if( cell.accessoryType == UITableViewCellAccessoryCheckmark){
_WSConstProfessionID=[thisRow objectForKey:_WSColumnProfessionID];
_WSConstProfessionName=[thisRow objectForKey:_WSColumnProfessionName];
_WSConstProfessionSelectedIndex=row ;
} else {
_WSConstProfessionID=#"0";
_WSConstProfessionName=#"Select";
_WSConstProfessionSelectedIndex=-1 ;
}
[self.navigationController popViewControllerAnimated:YES];
}
Please set this line in viewdidload method
tableView.allowsMultipleSelectionDuringEditing = true
After add this line Apply following code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSUInteger row = [indexPath row];
NSDictionary *thisRow=[self.professionArr objectAtIndex:row];
NSLog(#"%#",[thisRow description]);
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone){
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
if(_WSConstProfessionID!=nil && ![_WSConstProfessionID isEqual:#"0"] && ![_WSConstProfessionID isEqual:#""] &&_WSConstProfessionSelectedIndex!=row){
UITableViewCell *cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:_WSConstProfessionSelectedIndex inSection:0]];
if (cell != nil){
cell .accessoryType=UITableViewCellAccessoryNone;
}
}
if( cell.accessoryType == UITableViewCellAccessoryCheckmark){
_WSConstProfessionID=[thisRow objectForKey:_WSColumnProfessionID];
_WSConstProfessionName=[thisRow objectForKey:_WSColumnProfessionName];
_WSConstProfessionSelectedIndex=row ;
} else {
_WSConstProfessionID=#"0";
_WSConstProfessionName=#"Select";
_WSConstProfessionSelectedIndex=-1 ;
}
[self.navigationController popViewControllerAnimated:YES];
}
plz use this code
heare i take NSMutableArray array name categoryArray.
alloc this array into viewdidload().
categoryArray = [NSMutableArray array];
in categoryArray I add the _WSColumnProfessionName ids and handle the coditions.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
#try {
NSUInteger row = [indexPath row];
static NSString *MyIdentifier = #"tableCell";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:#"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *) currentObject;
}
}
}
cell.lblTitle.text = [thisRow objectForKey:_WSColumnProfessionName];
if (categoryArray.count == 0)
{
NSLog(#"category array is empty.");
}
else
{
NSString *s = [NSString stringWithFormat:#"%#",[[save_cat_array objectAtIndex:indexPath.row] valueForKey:#"category_id"]];
for (int p =0 ; p<categoryArray.count; p++)
{
NSString *b =[NSString stringWithFormat:#"%#",[categoryArray objectAtIndex:p]];
if ([s isEqualToString:b])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.lblTitle.textt = [[self.professionArr objectAtIndex:indexPath.row]valueForKey:_WSColumnProfessionName];
break;
}
else
{
cell.lblTitle.text = [[self.professionArr objectAtIndex:indexPath.row]valueForKey:_WSColumnProfessionName];
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
}
return cell;
}
#catch (NSException *exception) {
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
#try {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = ( UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone)
{
[categoryArray addObject:[[self.professionArr objectAtIndex:indexPath.row] valueForKey:_WSColumnProfessionID];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
NSString *a = [NSString stringWithFormat:#"%#",[self.professionArr objectAtIndex:indexPath.row] valueForKey:_WSColumnProfessionID]];
for (int i=0;i<categoryArray.count;i++)
{
if ([a isEqualToString:[NSString stringWithFormat:#"%#",[categoryArray objectAtIndex:i]]])
{
[categoryArray removeObjectAtIndex:i];
}
}
}
}
#catch (NSException *exception) {
}
}
you can also handle max 3 condition on base of categoryArray.count == 3
Related
When i scroll Table, checkmark is hide. I know because of Reusing Cell, but I dont know how to fix. Pls help me. Here is my code:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = #"Cell";
StudentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[StudentTableViewCell alloc] init];
}
if (_btnCancel.hidden == NO) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
I change check and uncheck in didSelectRowAtIndexPath:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cellCheck = [tableView cellForRowAtIndexPath:indexPath];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (_btnCancel.hidden == NO) {
if (cellCheck.accessoryType == UITableViewCellAccessoryNone) {
cellCheck.accessoryType = UITableViewCellAccessoryCheckmark;
TeacherInfo *courseStudent = studentQuitArray[indexPath.row];
[dict setObject:courseStudent.id_user forKey:#"student_id"];
[studentDetail addObject:dict];
} else {
cellCheck.accessoryType = UITableViewCellAccessoryNone;
[studentDetail removeObject: studentQuitArray[indexPath.row]];
}
}
}
When you scroll table view, cellForRowAtIndexPath for particular cell will be called in which your are setting the accessoryType as None. Instead try like below.
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = #"Cell";
StudentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[StudentTableViewCell alloc] init];
}
if (_btnCancel.hidden == NO) {
TeacherInfo *courseStudent = studentQuitArray[indexPath.row];
if ([studentDetail containsObject:courseStudent]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
didSelectRowAtIndexPath:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cellCheck = [tableView cellForRowAtIndexPath:indexPath];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (_btnCancel.hidden == NO) {
if (cellCheck.accessoryType == UITableViewCellAccessoryNone) {
cellCheck.accessoryType = UITableViewCellAccessoryCheckmark;
TeacherInfo *courseStudent = studentQuitArray[indexPath.row];
[dict setObject:courseStudent.id_user forKey:#"student_id"];
[studentDetail addObject:dict];
} else {
cellCheck.accessoryType = UITableViewCellAccessoryNone;
[studentDetail removeObject: studentQuitArray[indexPath.row]];
}
}
}
Hope this will help.
If you are reusing cells then you need to save the state of each cell .Because every time you scroll up and down, TableView will bring back the previous cell that outside of the screen.
You can save selectable state in an array and read its index in cellForRowAtIndexpath to get the current state of the cell.
You can also do this by adding one boolean property like is-selected in your "TeacherInfo" NSObject class,and set true false based on table-row selection.
Try this :
You need to add instance object of TeacherInfo instead of student id because your containedObject of array gives wrong result .
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = #"Cell";
StudentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[StudentTableViewCell alloc] init];
}
if (_btnCancel.hidden == NO) {
TeacherInfo *courseStudent = studentQuitArray[indexPath.row];
if ([studentDetail containsObject:courseStudent]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
didSelectRowAtIndexPath:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cellCheck = [tableView cellForRowAtIndexPath:indexPath];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (_btnCancel.hidden == NO) {
if (cellCheck.accessoryType == UITableViewCellAccessoryNone) {
cellCheck.accessoryType = UITableViewCellAccessoryCheckmark;
TeacherInfo *courseStudent = studentQuitArray[indexPath.row];
[studentDetail addObject:courseStudent];
} else {
cellCheck.accessoryType = UITableViewCellAccessoryNone;
[studentDetail removeObject: studentQuitArray[indexPath.row]];
}
}
}
I want to checkmark the data when the data is being loaded in the uitablecell. I know it works when you put it in the didselect section but can we use it in the cellForRowAtIndexPath. If yes how to use it? I have tried but it doesn't show any checkmarks.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = #"AddGoalsTableViewCell";
AddGoalsTableViewCell *cell = (AddGoalsTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"AddGoalsTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.addGoalsText.font = [UIFont fontWithName:#"AvenirNext-Medium" size:17];
cell.addGoalsText.textColor = [UIColor colorWithRed:102.0f/255.0f green:102.0f/255.0f blue:102.0f/255.0f alpha:1.0f];
cell.addGoalsText.text = [[goalsArray objectAtIndex:indexPath.row] valueForKey:#"name"];
PFObject *currentUser = [[goalsArray objectAtIndex:indexPath.row] valueForKey:#"user"];
User *user = [[User alloc] initWithUserId:[currentUser valueForKey:#"userID"] userName:[currentUser valueForKey:#"name"] anduserpassword:[currentUser valueForKey:#"password"]];
if(user==nil)
{
}
else if([[user userId]isEqualToString:[[NSString stringWithFormat:#"%#", [[[UIDevice currentDevice] identifierForVendor] UUIDString] ] lowercaseString]])
{
[self.tableView beginUpdates];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark; <------Here
[self.tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}
return cell;
}
Please refer following code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil )
{
cell =[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
if ([indexPath compare:self.lastIndexPath] == NSOrderedSame)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
// UITableView Delegate Method
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.lastIndexPath = indexPath;
[tableView reloadData];
}
And lastIndexPath is a property(retain) NSIndexPath* lastIndexPath;
i need to add checkmark when we tap on each cell, and it must show when i return back to tableview.
I tried with this code but its not working,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (self.thread == nil) {
cell.textLabel.text = #"Loading, please wait...";
} else if ([self.thread count] == 0) {
cell.textLabel.text = #"No Results!";
} else {
//
NSDictionary *msg = [self.thread objectAtIndex:indexPath.row];
NSLog(#"yourMutableDictionary - %#",msg);
if (indexPath.row == 0) {
cell.textLabel.text = [thread objectAtIndex:0];
} else {
cell.textLabel.text = [NSString stringWithFormat:#"%# ", [msg objectForKey:#"id"]];
if ([self.idSelected count] != 0) {
if ([self.idSelected containsObject:[NSString stringWithFormat:#"%#", [msg objectForKey:#"id"]]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
}
}
return cell;
}
#pragma mark - Table view delegate
//In a xib-based application, navigation from a table can be handled in - tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)path
{
if (self.thread == nil || self.thread.count == 0) {
return;
}
UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];
if (path.row == 0) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;// this checkmark not working
}
else {
NSDictionary *user = [self.thread objectAtIndex:path.row];
NSString *uName = [NSString stringWithFormat:#"%# %#", [user objectForKey:#"first_name"], [user objectForKey:#"last_name"]];
NSString *uId = [NSString stringWithFormat:#"%#",[user objectForKey:#"id"]];
NSLog(#" click id%#", uId);
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
[userNames removeObject:uName];
[userIds removeObject:uId ];
cell.accessoryType = UITableViewCellAccessoryNone; // this check mark is working perfectly
} else {
[userNames addObject:uName];
[userIds addObject:uId];
cell.accessoryType = UITableViewCellAccessoryCheckmark; // this check mark is working perfectly
}
}
}
first cell check mark is not working but others working perfectly. I want to add check mark on first cell too, how its possible
Use below code to display checkmark on multiple table view cell :
- (void)viewDidLoad
{
[super viewDidLoad];
self.arraySelectedCell = [NSMutableArray array];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.arraySelectedCell containsObject:indexPath])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
// do here..
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//the below code will allow multiple selection
if ([self.arraySelectedCell containsObject:indexPath])
{
[self.arraySelectedCell removeObject:indexPath];
}
else
{
[self.arraySelectedCell addObject:indexPath];
}
[tableView reloadData];
}
happy coding!
i have a tableview cell and this is binding from one array and select to multipal cell and set to checkmark but when i scroll table the checkmark is auto hide
and then i search on stackoverflow and i find one answier
the link is
UITableview accessory type disappear while scrolling
i tried this code but app is crash Here is my code, please Help me
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"FirstTableViewCell";
FirstTableViewCell *cell = (FirstTableViewCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"FirstTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
if(tableView ==nurseTypeTable){
cell.lbl1.text = [arrayNurseType objectAtIndex:indexPath.row];
if(_nurseArray.count != nil){
// if (_nurseArray == nil || [_nurseArray count] == 0) {
NSNumber *rowNsNum = [_nurseArray objectAtIndex:indexPath.row];
if ( [arrayNurseType containsObject:rowNsNum] )
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
return cell;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString * cellValue=nil;
if (tableView==nurseTypeTable) {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//Here is for Check
if(cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//here i add in array
cellValue=[arrayNurseType objectAtIndex:indexPath.row];
NSLog(#"%#",cellValue);
[_nurseArray addObject:cellValue];
NSLog(#"%#",_nurseArray);
}
//Here is for uncheck
else {
cellValue=[arrayNurseType objectAtIndex:indexPath.row];
[_nurseArray removeObject:cellValue];
cell.accessoryType = UITableViewCellAccessoryNone;
NSLog(#"Remove Array %#",_nurseArray);
}
// [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
in function cellForRowAtIndexPath **
NSNumber *rowNsNum = [_nurseArray objectAtIndex:indexPath.row];** is creash on debug time
arrayNurseType = [NSMutableArray arrayWithObjects:#" Nurse ",#"One",nil]
You should use
if(tableView ==nurseTypeTable){
cell.lbl1.text = [arrayNurseType objectAtIndex:indexPath.row];
if(_nurseArray.count != nil){
// if (_nurseArray == nil || [_nurseArray count] == 0) {
if ( [_nurseArray containsObject:indexPath] )
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
return cell;
}
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = #"LeftTable";
// LabDetailsVO* objLabDetailsVO=(LabDetailsVO* )dictData;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
NSArray *arrCurrentDataSource = [arrDataSource objectAtIndex:tableView.tag];
cell.textLabel.text = [arrCurrentDataSource objectAtIndex:indexPath.row];
cell.textLabel.font = FONT_ORDERS_LEFT_CELL;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
/**********************************************************************/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
int lastSelectedIndexPath = [[arrSelectedIndexPaths objectAtIndex:tableView.tag] intValue];
if (lastSelectedIndexPath != -1) {
cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:lastSelectedIndexPath inSection:0]];
cell.accessoryType = UITableViewCellAccessoryNone;
}
[arrSelectedIndexPaths replaceObjectAtIndex:tableView.tag withObject:[NSString stringWithFormat:#"%d", indexPath.row]];
cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//Notify the parent controller about the new value selected by the user.
if ([idParentDelegate respondsToSelector:#selector(popOverSelectionNotifier: value: )]) {
[idParentDelegate popOverSelectionNotifier:tableView.tag value:[NSString stringWithFormat:#"%d", indexPath.row]];
}
else {
NSLog(#"Error : %# - Does not protocol(OrdersDetailPopViewControllerSelectionDelegate) method (popOverSelectionNotifier: value:)", NSStringFromClass([idParentDelegate class]));
}
}
Table view reuse the cell when it scroll,you reset design and values in cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
........
if (cell == nil)
{
..........
..........
}
if(lastSelectedIndexPath != -1)
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
else
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
return cell;
}