Kevin
Kevin

Reputation: 31

How to programmatically use UIButton in iPhone Development

I encountered a weird problem. when I try to add a UIButton in my customized ui view. the button title cannot display. only draw the outside roundrect. regardless invoke setTitle:forState: or button.backgroundColor=[UIColor redColor]; it also doesn't work. but for backgroundColor, at the rectangle angle corner, the bgcolor seems take a little bit filling up.

I initialized this button in "initWithNibName" method of custom view controller. is it ok? even I set this button reference to view controller's view property or just added it into other view. this issue also happens.

Upvotes: 0

Views: 579

Answers (1)

Ben Gottlieb
Ben Gottlieb

Reputation: 85532

You should set your button values in -viewDidLoad. If you try to do this in -initWithNibNamed:bundle:, the outlets won't be set up yet, and your button value will be nil.

Upvotes: 2

Related Questions