ios - How to set the default-state Image for UIButton? -


i totally confused. want set image default-state of list of uibuttons. in not work. assigned image buttons inside setter of outlet-collection image appears if button highlighted want image set except button selected. code far :

-(void)setcardbuttons:(nsarray *)cardbuttons {     uiimage * cardbackimage = [uiimage imagenamed:@"card-back.jpg"];     (uibutton * button in cardbuttons) {         [button setimage:cardbackimage forstate:uicontrolstatenormal|uicontrolstatehighlighted];         [button setimage:nil forstate:uicontrolstateselected];     }     _cardbuttons = cardbuttons; } 

i dont know doing wrong ? how can set image of default-state-button without using ib ?

there few states can use, make sure set them correctly. copy , paste xcode , fill in images tabbing through.

might worth while refreshing memory reading the apple doc this.

[button setimage:<# normal image #> forstate:uicontrolstatenormal]; [button setimage:<# selected image #> forstate:uicontrolstateselected]; [button setimage:<# highlighted image #> forstate:uicontrolstatehighlighted]; [button setimage:<# selected , highlighted image #> uicontrolstateselected | forstate:uicontrolstatehighlighted]; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -