Try this for a radio button in iOS:
@interface RadioButtonViewController : UIViewController
{
//for radio button
IBOutlet UIButton *radioButton1;
IBOutlet UIButton *radioButton2;
IBOutlet UITextField *selectedValue;
IBOutlet UILabel *label1;
IBOutlet UILabel *label2;
}
@property (nonatomic,retain) IBOutlet UIButton *radioButton1;
@property (nonatomic,retain) IBOutlet UIButton *radioButton2;
@property (nonatomic,retain) IBOutlet UITextField *selectedValue;
-(IBAction)userChangedButtonClicked:(id)sender
@end
Write code in .m file and specify the default and selected image in storyboard inspector window and give the tag value each button.
RadioButtonViewController.m
-(IBAction)userChangedButtonClicked:(id)sender
{
UIButton *senderBtn = (UIButton*)sender;
if (senderBtn.tag == 101 && !self.radioButton1.selected)
{
self.radioButton1.selected = TRUE;
self.radioButton2.selected = FALSE;
selectedValue.text = label1.text;
}else if (senderBtn.tag == 102 && !self.radioButton2.selected)
{
self.radioButton1.selected = FALSE;
self.radioButton2.selected = TRUE;
selectedValue.text = label2.text;
}
}