views:

20

answers:

1

This seems to work, but then the program crashes right after the button get highlighted.

-(IBAction) buttonPressed: (id) sender
{
    [sender setHighlighted:YES];    
}

How should this be diffeent? What would it look like if I wanted to highlight the button if it was not previously highlighted, and return the button to its normal state if it was?

+1  A: 

The answer is probably do nothing. NSButton in Cocoa handles this for free; it would surprise me if UIButton didn't do the same.

If the answer is not do nothing, it's to set a different background image for the relevant control states. If you're already customizing it, then you'll want to do this anyway.

Either way, you should not handle this in your action.

Peter Hosey