views:

36

answers:

3

i am new to iphone development.. i am making an application in which table view list the names of countries... user has to select one or more countries at a time..i want to display the checkmark disclosure button at the entries that are selected..how can i do that..

and another thing..i want to deselect the entry when user again clicks on the same name..means the checkmark will be removed..

+1  A: 

here is a good tutorial that will help you

Gyani
thank you....i must read it..
Kuldeep Sidhu
+1  A: 

To show the checkmark:

cell.accessoryType = UITableViewCellAccessoryCheckmark

To clear the checkmark:

cell.accessoryType = UITableViewCellAccessoryNone

You can toggle this easily by testing the current value.

taskinoor
A: 

in the method,

        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
            (NSIndexPath *)indexPath {
            // You have an array of countries and track all indexes that are selected.
            // If the indexing is synced with the cell index, then 
            UITableViewCell *thisCell = [tableView cellForRowAtIndexPath:indexPath];
            if (/* this index's country is selected */)
                cell.accessoryType = UITableViewCellAccessoryNone;
            else {
                // update this index's country to selected state.
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            // you can keep an array of indexes, which cells/country is selected and store the status of selection in the array for further use.
            }
        }
karim
it solved my problem but now the problem is. like on first screen i have selected 3 entries and when i scroll through the lower entries(on next screen ) it shows that three entries pre selected but in actual these are not selected...how can i correct this problem..i have a list to 200 countries..
Kuldeep Sidhu
that is because the cells are reused. I can edit my the answer little for a solution to it.
karim