Why does my UIButton.titleLabel.text disappear when I place an image in the button?

Posted by nickthedude on Stack Overflow See other posts from Stack Overflow or by nickthedude
Published on 2010-04-13T03:49:58Z Indexed on 2010/04/13 3:52 UTC
Read the original article Hit count: 441

I've had this problem before but was able to work around it until now, Basically I'm creating a custom UIbutton setting its image as a uiimage and then the button that has had a label until I implimented the below code now loses its label. I need that label because it is set programatically in code that follows.

 NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ];
            UIImage *image = [UIImage imageNamed:imageName];
            [button setImage:image forState:UIControlStateNormal ];

Any help you could lend would be mucho appreciated.

-nick

© Stack Overflow or respective owner

Related posts about uibutton

Related posts about textlabel