hi, i am using radio button image (empty circle) in button to answer the question from 3 options, and the 3 options are radio button's. i have created 3 uibuttons programmatically in tableview delegate method cellforrowatindexpath. i need when one button is selected(with filled circle image) other one if selected before gets unselected. i am using below code in button clicked method.
static int _row;
-(IBAction) optionClicked:(id)sender { UIButton *btn = (UIButton)sender; _row = btn.tag;
if (btn.tag == 0)
{
if(btn1On)
{
[btnrad1 setImage:[UIImage imageNamed:@"unfilled.png"]forState:UIControlStateNormal];
btn1On=FALSE;
}
else
{
[btnrad1 setImage:[UIImage imageNamed:@"filled.png"]forState:UIControlStateNormal];
btn1On = TRUE;
btn2On = FALSE;
btn3On = FALSE;
}
}
else if (btn.tag == 1)
{
if(btn2On)
{
[btnrad2 setImage:[UIImage imageNamed:@"unfilled.png"]forState:UIControlStateNormal];
btn2On=FALSE;
}
else
{
[btnrad2 setImage:[UIImage imageNamed:@"filled.png"]forState:UIControlStateNormal];
btn2On = TRUE;
btn1On = FALSE;
btn3On = FALSE;
}
}
else if (btn.tag == 2)
{
if(btn3On)
{
[btnrad3 setImage:[UIImage imageNamed:@"unfilled.png"]forState:UIControlStateNormal];
btn3On=FALSE;
}
else
{
[btnrad3 setImage:[UIImage imageNamed:@"filled.png"]forState:UIControlStateNormal];
btn3On = TRUE;
btn1On = FALSE;
btn2On = FALSE;
}
}
else
{
NSLog(@"Error");
}
}
above code is doing selection of button in another row. like i am selecting 1st option in 1st row but its is selecting 2nd row button. i don't know how to use _row to check for every cell of table view.