i have create a UIBUtton
editButton = [[UIButton alloc]initWithFrame:CGRectMake(width, -4, 30, 30)];
[editButton setImage:[UIImage imageNamed:#"DeleteButton.jpg"] forState:UIControlStateNormal];
[editButton addTarget:self action:#selector(deleteObjectViewImage:) forControlEvents:UIControlEventTouchUpInside];
editButton.hidden = YES;
[editButton setTag:tag];
[backView addSubview:editButton];
But control not jump to its definition where i check if button give its tag value on click or not.
-
(void)deleteObjectViewImage
{
NSInteger index = editButton.tag;
editButton.hidden = YES;
}
Can anyone tell me why it not work please.
Use this line instead of line in your code (colon removed after function name),
[editButton addTarget:self action:#selector(deleteObjectViewImage) forControlEvents:UIControlEventTouchUpInside];
[editButton addTarget:self action:#selector(deleteObjectViewImage:) forControlEvents:UIControlEventTouchUpInside];
expects the function deleteObjectViewImage: to have one argument. But the function definition doesnt has any.
UPDATE:
-(void)deleteObjectViewImage: (id) sender
{
UIButton *clickedButton = (UIButton *) sender;
NSInteger index = clickedButton.tag;
editButton.hidden = YES;
}
and use
[editButton addTarget:self action:#selector(deleteObjectViewImage:) forControlEvents:UIControlEventTouchUpInside];
For getting Tag Value you have to write this code in Button Click event...
-(IBAction)deleteObjectViewImage:(id)sender
{
UIButton *btn = (UIButton *)sender;
NSLog(#"%d",btn.tag);
}
Don't remove colon from
[editButton addTarget:self action:#selector(deleteObjectViewImage:) forControlEvents:UIControlEventTouchUpInside];
Try this
editButton = [[UIButton alloc]initWithFrame:CGRectMake(width, -4, 30, 30)];
[editButton setImage:[UIImage imageNamed:#"DeleteButton.jpg"] forState:UIControlStateNormal];
[editButton addTarget:self action:#selector(deleteObjectViewImage:) forControlEvents:UIControlEventTouchUpInside];
editButton.hidden = YES;
[editButton setTag:tag];
[backView addSubview:editButton];
- (void)deleteObjectViewImage:(id)sender
{
UIButton *button = (UIButton *)sender;
NSLog(#"Button tag is %d",button.tag);
button.hidden = YES;
}
Related
I had an application in which I am adding some dynamic number of buttons to a scrollview. I had set a normal background and selected background for the UIButton. For some reasons I need to call the UIButton sender method programmatically by:
[self buttontapped:nil];
as this but it is not changing the background of the button by using the code:
button.selected = YES;
I had set the background like this initially of the button:
btn = [UIButton buttonWithType:UIButtonTypeCustom];
int j = i+1;
btn.frame = CGRectMake((j-1)*77, 0, 77, 44);
[btn setBackgroundImage:[UIImage imageNamed:#"bar.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:#"bar_hvr.png"] forState:UIControlStateSelected];
btn.selected = NO;
btn.backgroundColor = [UIColor clearColor];
btn.titleLabel.font = [UIFont fontWithName:#"Helvetica-Bold" size:14];
btn.titleLabel.textColor = [UIColor whiteColor];
[btn setTitle:head forState:UIControlStateNormal];
btn.tag = i;
[tabBarS addSubview:btn];
-(void)buttonTapped:(id)sender {
if(sender==nil)
{
btn.tag=0;
}
for(int i=0;i<[sarray count];i++)
{
btn.selected=NO;
}
btn = (UIButton *)sender;
NSLog(#"Tab bar %d is clicked",btn.tag);
[self tabCall:btn.tag];
btn.selected = YES;
}
But everything except change of background only working. Where am I going wrong?
i done with bellow method call your UIButton method like:-
btn= [UIButton buttonWithType:UIButtonTypeCustom];
int j=i+1;
btn.frame = CGRectMake((j-1)*77, 0, 77, 44);
[btn setBackgroundImage:[UIImage imageNamed:#"bar.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:#"bar_hvr.png"] forState:UIControlStateSelected];
btn.selected=NO;
[btn addTarget:self action:#selector(yourButtonAction:) forControlEvents:UIControlEventTouchUpInside];
btn.backgroundColor = [UIColor clearColor];
btn.titleLabel.font = [UIFont fontWithName:#"Helvetica-Bold" size:14];
btn.titleLabel.textColor = [UIColor whiteColor];
btn.tag = i;
[tabBarS addSubview:btn];
and it's Action Method should like with sender
-(IBAction)yourButtonAction:(id)sender
{
UIButton *btn = (UIButton*)sender;
if (![btn isSelected])
{
[btn setImage:[UIImage imageNamed:#"selected_fb_btn.png"] forState:UIControlStateNormal];
[btn setSelected:YES];
[self login];
}
else{
[btn setImage:[UIImage imageNamed:#"facebook.png"] forState:UIControlStateNormal];
[btn setSelected:NO];
}
}
EDIT
You can call button action event programeticuly using bellow trik:-
[btn sendActionsForControlEvents:UIControlEventTouchUpInside];
write this bellow line first and also change the method type from void to IBAction...
btn = (UIButton *)sender;
like bellow...
-(IBAction)buttonTapped:(id)sender {
btn = (UIButton *)sender;
if(sender==nil)
{
btn.tag=0;
}
for(int i=0;i<[sarray count];i++)
{
[btn setSelected:NO];
}
NSLog(#"Tab bar %d is clicked",btn.tag);
[self tabCall:btn.tag];
[btn setSelected:YES];
}
You need to set image property rather than backgroundImage property of UIButton.
Use default Image property and selected property.
[btn setSelected:TRUE];
is the log that you are printing, prints the button.tag correctly?
NSLog(#"Tab bar %d is clicked",btn.tag);
In your button action
btn.selected=YES;
in last line makes the button in selected state always
also get the correct instance as
btn=(UIButton *)sender;
When I click inside text box, How can I add plus button to UITextField as shown in the following screen? When this button is clicked it would launch iPhone contact application. I would very much appreciate any code example. Thanks
Following code use for adding button in UITextField.
-(void)ViewDidLoad{
UITextField *txt = [[UITextField alloc]initWithFrame:CGRectMake(140, 120, 160, 40)];
txt.returnKeyType = UIReturnKeyDone;
txt.placeholder = #"Enter or Mobile Number";
[txt setBorderStyle:UITextBorderStyleRoundedRect];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:#"crossImg.png"] forState:UIControlStateNormal];
button.imageEdgeInsets = UIEdgeInsetsMake(0, -16, 0, 0);
[button addTarget:self action:#selector(clearText:) forControlEvents:UIControlEventTouchUpInside];
txt.rightView = button;
txt.rightViewMode = UITextFieldViewModeAlways;
[self.view addSubview:txt];
}
-(IBAction)clearText:(id)sender{
}
You can use the below code for this:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if(textField == yourFirstTextField)
{
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addButton setImage:[UIImage imageNamed:#"addImage.png"] forState:UIControlStateNormal];
[addButton addTarget:self action:#selector(yourActionHere) forControlEvents:UIControlEventTouchUpInside];
textField.rightViewMode = UITextFieldViewModeWhileEditing;
textField.rightView = addButton;
}
}
You can use the above method if you added the field in IB.
If you are created it through code, you need to add the below code when creating:
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addButton setImage:[UIImage imageNamed:#"addImage.png"] forState:UIControlStateNormal];
[addButton addTarget:self action:#selector(yourActionHere) forControlEvents:UIControlEventTouchUpInside];
textField.rightViewMode = UITextFieldViewModeWhileEditing;
textField.rightView = addButton;
Use following method for add UIButton
[self.txtField addTarget:self action:#selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- (BOOL) textFieldDidChange:(UITextField *)textField
{
UIButton *btnColor = [UIButton buttonWithType:UIButtonTypeCustom];
[btnColor addTarget:self action:#selector(btnColorPressed:) forControlEvents:UIControlEventTouchUpInside];
btnColor.frame = CGRectMake(self.txtTag.bounds.size.width - 50, 5, 25, 25);
[btnColor setBackgroundImage:[UIImage imageNamed:#"PaintPickerButton.png"] forState:UIControlStateNormal];
[self.txtTag addSubview:btnColor];
return YES;
}
Or Write
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.3f];
// self.scrollView.frame = CGRectMake(0, 35, self.view.bounds.size.width, self.view.bounds.size.height - 250);
[UIView commitAnimations];
UIButton *btnColor = [UIButton buttonWithType:UIButtonTypeCustom];
[btnColor addTarget:self action:#selector(btnColorPressed:) forControlEvents:UIControlEventTouchUpInside];
btnColor.frame = CGRectMake(150, 5, 25, 25);
[btnColor setBackgroundImage:[UIImage imageNamed:#"PaintPickerButton.png"] forState:UIControlStateNormal];
[self.txtField addSubview:btnColor];
return YES;
}
Use rightView property of UITextField.
In textFieldDidBeginEditing: delegate create button with action you want & set to rightView.
And in textFieldDidEndEditing: set nil to rightView
you can also go for custom view ant then add sub view to it. then you hide it. it will be visible only when the user taps it
self.locationName.clearButtonMode = UITextFieldViewModeWhileEditing;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 30, 30);
[button setImage:[UIImage imageNamed:#"goButtonIcon.png"] forState:UIControlStateNormal];
[button addTarget:self action:#selector(goButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
self.locationName.rightView = button;
self.locationName.rightViewMode = UITextFieldViewModeUnlessEditing;
and then call this method:
-(IBAction)goButtonClicked:(id)sender{
}
self.locationName -------> UITextField Reference (in ViewDidload you can write this code)
I'm trying for hours to make a left button work properly and mimic a back button.
My code to create the button:
UIBarButtonItem *backButton = [self customBarButton:#"back_button" imageHiglighted:#"settings_button_highlighted" x:20 y:0 widthDivider:2.6 heightDivider:2.6];
backButton.target = self;
backButton.action = #selector(buttonPressed:);
self.navigationItem.leftBarButtonItem = backButton;
Here the method called to create custom button:
- (UIBarButtonItem *)customBarButton:(NSString *)imageDefault imageHiglighted:(NSString *)imageHighlighted x:(float)x y:(float)y widthDivider:(float)widthDivider heightDivider:(float)heightDivider {
UIImage *customImageDefault = [UIImage imageNamed:imageDefault];
UIImage *customImageHighlighted = [UIImage imageNamed:imageHighlighted];
CGRect frameCustomButton = CGRectMake(x, y, customImageDefault.size.width/widthDivider, customImageDefault.size.height/heightDivider);
UIButton *customButton = [[UIButton alloc] initWithFrame:frameCustomButton];
[customButton setBackgroundImage:customImageDefault forState:UIControlStateNormal];
[customButton setBackgroundImage:customImageHighlighted forState:UIControlStateHighlighted];
UIBarButtonItem *barCustomButton =[[UIBarButtonItem alloc] initWithCustomView:customButton];
return barCustomButton;
}
And the action:
-(void)buttonPressed:(id) sender{
NSLog(#"Entered");
SearchViewController *ViewController = [[SearchViewController alloc] init];
[self.navigationController pushViewController:ViewController animated:YES];
}
So I was able to make it with a simple UIButton but not with a UIButtonBarItem and I really don't know what's going on with it.
If you could help me I'd be very grateful.
Thanks.
Do this add selector to custom button as it is view of bar buttom:
[customButton addTarget:self action:#selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
EDIT : Note : the target and action of the UIBarButtonItem apply to custom views.
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:#"goback.png"] forState:UIControlStateNormal];
[button addTarget:self action:#selector(//HERE ! i don't know put what thing !) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 32, 32)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
TRY THIS
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:[GlobalMethods buttonWithImage:#"top-nav-back" heighlightImageName:nil buttonFrame:CGRectMake(102, 1, 50, 30) selectorName:#selector(btnBackClicked:) target:self]];
+ (UIButton*)buttonWithImage:(NSString*)normalImageName heighlightImageName:(NSString*)heighlightImageName buttonFrame:(CGRect)buttonFrame selectorName:(SEL)selectorName target:(id)target
{
UIButton *objButton = [UIButton buttonWithType:UIButtonTypeCustom];
[objButton setFrame:buttonFrame];
[objButton addTarget:target action:selectorName forControlEvents:UIControlEventTouchUpInside];
[objButton setImage:[GlobalMethods getImageFromResourceBundle:normalImageName] forState:UIControlStateNormal];
if(heighlightImageName)
[objButton setImage:[GlobalMethods getImageFromResourceBundle:heighlightImageName] forState:UIControlStateDisabled];
if(heighlightImageName)
[objButton setImage:[GlobalMethods getImageFromResourceBundle:heighlightImageName] forState:UIControlStateSelected];
return objButton;
}
Try this..
[customButton addTarget:self action:#selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
in your customBarButton method..
I mean to say give selector to your button instead of bar button item..
Check and reply..
Just put this line in your code..
[backButton addTarget:self action:#selector(backBtnPressed:) forControlEvents:UIControlEventTouchUpInside];
This worked for me
UIButton * tmpButton = [self generateButtonwithImageName:#"Back.png" andSize:CGRectMake(0, 0, 55, 30)];
UIBarButtonItem * backButton = [[UIBarButtonItem alloc] initWithCustomView:tmpButton];
[tmpButton addTarget:self action:#selector(reload) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem=backButton;
-(UIButton*)generateButtonwithImageName :(NSString*)imageName andSize:(CGRect)rect{
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame=rect;
[button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
return button;
}
//working for me
if([version floatValue] < 7.0)
{
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"navi-bar.png"] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.opaque = YES;
closeButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 35, 30)];
[closeButton setImage:[UIImage imageNamed:#"btn_end.png"] forState:UIControlStateNormal];
[closeButton setImage:[UIImage imageNamed:#"btn_end_on.png"] forState:UIControlStateHighlighted];
[closeButton addTarget:self action:#selector(actionClose) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:closeButton];
}
else{
/*add button back to navigation*//*add buttom back to navigation*/
UIBarButtonItem *itemBack = [[UIBarButtonItem alloc]initWithTitle:#"完了" style:UIBarButtonItemStylePlain target:self action:#selector(actionClose)];
self.navigationItem.rightBarButtonItem = itemBack;
}
i am creating an application which includes dynamic pages. actually, i created some dynamic questions and UIButtons (custom checkBox) by checking the responses from the server.
my code is here,
NSString *response=[ResponseFromServer ObjectAtIndex:0];
if ([comSt compare: #"CheckBoxList"]==NSOrderedSame)
{
int count=[ResponseFromServer count];
for(int i=0;i<count;i++)
{
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.tag=i;
[button setFrame:CGRectMake(0.0f, 0.0f, 37, 37)];
[button setCenter:CGPointMake(116.0,p1)];
[button setImage:[UIImage imageNamed:#"uncheck.png"] forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor whiteColor]];
[button addTarget:self action:#selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:button];
p1=p1+30;
}
-(void)checkButtonTapped:(id)sender
{
int tagVal = [(UIButton*)sender tag];
if (tagVal==0) {
NSLog(#"tag = 0");
[button setSelected:YES];
[button setImage:[UIImage imageNamed:#"check.png" forState:UIControlStateSelected]; //not working, button image is not changing
}
assume i have created 5 dynamic buttons with different tag. i set the image for all those button to uncheck.png first. it works.
but when i clicked a specific button and need to change that button image to checked.png, its not working on the button action.
i need to change it like checkBox control, how will i access the control of a dynamically created button from a group of buttons?
i think u can understand my requirement, thanks in advance..
While adding dynamic button set [button setSelected:NO];
Replace method and Add one method given below
-(void)checkButtonTapped:(id)sender
{
UIButton *curButton = (UIButton*)sender
if (curButton.tag==0)
{
[self buttonAction:curButton];
}
if (curButton.tag==1)
{
[self buttonAction:curButton];
}
// continues
}
-(void)buttonAction:(UIButton *)curButton
{
if(![curButton isSelected])
{
[curButton setSelected:YES];
[curButton setImage:[UIImage imageNamed:#"check.png" forState:UIControlStateSelected]; //not working, button image is not changing
} else {
[curButton setSelected:NO];
[curButton setImage:[UIImage imageNamed:#"uncheck.png"] forState:UIControlStateNormal];
}
}
In your code you need to change like this
Try this code
if ([comSt compare: #"CheckBoxList"]==NSOrderedSame)
{
int count=[ResponseFromServer count];
for(int i=0;i<count;i++)
{
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.tag=0;
[button setFrame:CGRectMake(0.0f, 0.0f, 37, 37)];
[button setCenter:CGPointMake(116.0,p1)];
[button setImage:[UIImage imageNamed:#"uncheck.png"] forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor whiteColor]];
[button addTarget:self action:#selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:button];
p1=p1+30;
}
}
-(void)checkButtonTapped:(id)sender
{
int tagVal = [(UIButton*)sender tag];
if (tagVal==0) {
NSLog(#"tag = 0");
[button setSelected:YES];
[button setImage:[UIImage imageNamed:#"check.png" forState:UIControlStateSelected];
[button setTag:100];
}
else
{
[button setSelected:YES];
[button setImage:[UIImage imageNamed:#"uncheck.png" forState:UIControlStateSelected];
[button setTag:0];
}
}
I have dynamically created some list of RadioButtons with some values. pro grammatically I changed the button state and changed the image for selected and unselected. but the problem is i can select the all radioButtons at same time. actually I need to select one at a time.
when I clicked the next RadioButton, previously selected button state should be changed to non-selected.
Here is my code, I tried with changing image, but ...some problem with my code.
RadioButton = [UIButton buttonWithType:UIButtonTypeCustom];
[RadioButton setFrame:CGRectMake(0.0f, 0.0f, 20, 20)];
[RadioButton setCenter:CGPointMake(116.0,p1)];
[RadioButton setSelected:NO];
[RadioButton setImage:[UIImage imageNamed:#"uncheck.png"] forState:UIControlStateNormal];
[RadioButton addTarget:self action:#selector(RadioButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:RadioButton];
-(void)RadioButtonTapped:(id)sender
{
UIButton *RadioButton1 = (UIButton*)sender ;
[self radiobuttonAction:RadioButton1];
}
-(void)radiobuttonAction:(UIButton *)Button
{
if(![Button isSelected])
{
[Button setSelected:YES];
[Button setImage:[UIImage imageNamed:#"radio_active.png"] forState:UIControlStateSelected]; //not working, button image is not changing
}
else
{
[Button setSelected:NO];
[Button setImage:[UIImage imageNamed:#"radio_inactive.png"] forState:UIControlStateNormal];
}
}
where can I change the image of previously selected button.
thanks in advance
Deselect all the buttons when you select one. If you have buttons in your scroll view you can user this code:
//Your Method
-(void)RadioButtonTapped:(id)sender
{
UIButton *RadioButton1 = (UIButton*)sender;
[self deselectAll];
[self radiobuttonAction:RadioButton1];
}
- (void) deselectAll : (UIScrollView *) scrollView{
NSArray *viewArray = [scrollView subviews];
for (UIView *v in viewArray){
if([v isKindOfClass:[UIButton class]]){
[((UIButton *)v) setSelected:NO];
}
}
}
EDIT: But if you want to give it real radio button effect (in which one is always selected, and only one is selected) it will be more easy to you. Use following code:
//A globle refButton
UIButton *refButton = nil;
//Set image for both state:
[RadioButton setImage:[UIImage imageNamed:#"uncheck.png"] forState:UIControlStateNormal];
[RadioButton setImage:[UIImage imageNamed:#"check.png"] forState:UIControlStateSelected];
//make any of above default select: may be the last one and pass that to `refButton`
refButton = RadioButton;
//Your Method
-(void)RadioButtonTapped:(id)sender
{
[refButton setSelected:NO];
refButton = (UIButton*)sender;
[refButton setSelected:YES];
}
Tag the button at the time of creation.
When button tapped, get the buttons through tag. Deselect all buttons. Update current button which you have received as a n argument.
assuming you want to add 5 radio buttons.
- (void)viewDidLoad
{
for (int i = 0; i < 5; i++) {
UIButton* RadioButton = [UIButton buttonWithType:UIButtonTypeCustom];
[RadioButton setFrame:CGRectMake(0.0f, 0.0f, 20, 20)];
[RadioButton setCenter:CGPointMake(116.0, i * 40)];
// [RadioButton setTag:i * 10];
[RadioButton setSelected:NO];
[RadioButton setImage:[UIImage imageNamed:#"unCheck.png"] forState:UIControlStateNormal];
[RadioButton addTarget:self action:#selector(RadioButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:RadioButton];
}
}
//do not forget to declared this in your header file
-(void)RadioButtonTapped:(UIButton*)button;
{
for (UIButton *btn in self.scrollView.subviews) {
[btn setImage:[UIImage imageNamed:#"unCheck.png"] forState:UIControlStateNormal];
}
[button setImage:[UIImage imageNamed:#"check.png"] forState:UIControlStateNormal];
}
the code above updates the UI, sets the image of all buttons to "uncheck" then changes the image of the last pressed button to "check".
create buttons like this,
for(int i=0;i<4;i++)
{
RadioButton = [UIButton buttonWithType:UIButtonTypeCustom];
RadioButton.tag = i*100;
[RadioButton setFrame:CGRectMake(0.0f, 0.0f, 20, 20)];
[RadioButton setCenter:CGPointMake(116.0,p1)];
[RadioButton setSelected:NO];
[RadioButton setImage:[UIImage imageNamed:#"uncheck.png"] forState:UIControlStateNormal];
[RadioButton addTarget:self action:#selector(RadioButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:RadioButton];
}
add action like this,
-(void)radiobuttonAction:(UIButton *)Button
{
UIButton *Button = (UIButton*)sender;
for(UIButton * btn in self.scrollview.subViews)
{
if(btn.tag == Button.tag)
{
if(![Button isSelected])
{
[Button setSelected:YES];
[Button setImage:[UIImage imageNamed:#"radio_active.png"] forState:UIControlStateSelected]; //not working, button image is not changing
}
else
{
[Button setSelected:NO];
[Button setImage:[UIImage imageNamed:#"radio_inactive.png"] forState:UIControlStateNormal];
}
}
else
{
//do selected or de-selected code for other buttons
}
}