当我在按钮中放置图像时,为什么我的UIButton.titleLabel.text会消失?

nic*_*ude 3 iphone cocoa-touch uibutton uiview textlabel

我以前遇到过这个问题,但是到目前为止我能够解决这个问题,基本上我正在创建一个自定义UI按钮,将其图像设置为uiimage,然后在我使用下面的代码之前有一个标签的按钮现在丢失了它的标签.我需要该标签,因为它是以编程方式在后面的代码中设置的.

 NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ];
            UIImage *image = [UIImage imageNamed:imageName];
            [button setImage:image forState:UIControlStateNormal ];
Run Code Online (Sandbox Code Playgroud)

任何你可以借出的帮助都会非常感激.

-缺口

nic*_*ude 5

我需要做一个:

[button setBackroundImage:image forState:UIControlStateNormal ];
Run Code Online (Sandbox Code Playgroud)

而不是这个:

[button setImage:image forState:UIControlStateNormal ];
Run Code Online (Sandbox Code Playgroud)

;)