NSButton setImage not working

半城伤御伤魂 提交于 2020-01-25 10:37:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!