I have an IPhone application in which I am using an IBOutlet button with a background. On its click, I call a webservice and on the success of that, I need to change the background of the button. Now I am doing it in this way but nothing’s happening:
UIImage *buttonImage = [UIImage imageNamed:@"follow_shop.png"];
[following setBackgroundImage:buttonImage forState:UIControlStateNormal];
Does anybody know how to achieve this?
What you have done in code is correct. You can do three things now (in decreasing order of probability of finding the issue):
1) Check in your IB if initially, you have set its
imageorbackgroundImage. The two are different andimagecomes above thebackgroundImage(effectively renderingbackgroundImageas being hidden). Both of these (the image you set in IB and in code) should be either one (imageorbackgroundImage).2) Check if
follow_shop.pngis the correct name. You can also use breakpoints to see ifbuttonImagehas memory or not.3) Check if
followingis connected in your IB.