0

に表示されるオプション値のリストがありますUITableView

Now I want user to select one item once. But currently the user can select all the option.

What I want :

Suppose I Have 5 radio boxes : 1 2 3 4 5 at a time user can only select one . If he choses another one then Previous one must get deselected.

What is Happening Now:

Currently all of the boxes are get selected.

I am using this code in my didSelectRowAtIndex method:

 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
 UIButton *btnRadhio = (UIButton *)[cell viewWithTag:1];

 for(int i =0;i<[arrDistanceList count];i++)
   {
     [btnRadhio setBackgroundImage:[UIImage imageNamed:@"radio_unchecked"] forState:UIControlStateNormal];
   }

    [btnRadhio setBackgroundImage:[UIImage imageNamed:@"radio_checked"] forState:UIControlStateNormal];
4

4 に答える 4

0

CellforRowAtIndexPath:

cell.btnRadhio.tag = (indexpath.row+1)*100;

DisselectRowAtIndexPath:

for(int i =0;i<[arrDistanceList count];i++)
{
   UIButton *btnRadhio = (UIButton *)[self.view viewWithTag:(i+1)*100];
   if(i==indexpath.row)
   {
   [btnRadhio setBackgroundImage:[UIImage imageNamed:@"radio_checked"] forState:UIControlStateNormal];
   }
   else
   {
   [btnRadhio setBackgroundImage:[UIImage imageNamed:@"radio_unchecked"] forState:UIControlStateNormal];
   }
}

これがあなたを助けることを願っています。

于 2015-08-10T06:55:54.293 に答える