问题
I am trying to change the image of my nsbutton for my application. I have searched and found a couple of ways to do so but none of them are working for me at the moment.
I have looked at the following solutions :
How to set NSButton background image Using -setImage on NSButton
I have a routine that is called when I click the button :
- (IBAction)pauseResumeButtonAction:(id)sender
{ IAgentInterface* agentInterface = ioc::Container::Resolve();
if (self.pauseResumeSwitch == PauseResumeSwitch::PAUSE)
{
//if ready to pause do this
AgentCommand cmd( AGENT_CMD_PAUSE_SERVICE);
agentInterface->sendAgentCommand( cmd );
self.pauseResumeSwitch = PauseResumeSwitch::RESUME;
[self.pauseResumeButton setImage:[NSImage imageNamed:@"pause.png"]];
}
else if (self.pauseResumeSwitch == PauseResumeSwitch::RESUME)
{
//else if ready to resume do this
AgentCommand cmd( AGENT_CMD_RESUME_SERVICE);
agentInterface->sendAgentCommand( cmd );
self.pauseResumeSwitch = PauseResumeSwitch::PAUSE;
[self.pauseResumeButton setImage:[NSImage imageNamed:@"resume.png"]];
}
}
can someone please help me find my mistake ? it will be of great help
thanks in advance :)
来源:https://stackoverflow.com/questions/23687118/nsbutton-setimage-not-working