Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJose Colella
3,526 PointsChanging the Button background image on click
I tried implementing the button programmatically, and I'm having trouble changing the image onclick. I used [self.predictButton setBackgroundImage:[UIImage imageNamed:@"button-on"] forState:UIControlStateNormal]; but it doesn't do anything.
1 Answer
Jose Colella
3,526 PointsI fixed the problem.
After changing the button to UIButtonTypeCustom
, it works.
self.predictButton = [UIButton buttonWithType:UIButtonTypeCustom];
I have no idea why the event does not do anything to a UIButton of type UIButtonTypeRoundedRect
.