开发者

How to highlight a button when it is pressed

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 i开发者_开发知识库ts normal state if it was?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜