I have an IBAction that acts as a toggle switch for one of my functions; how can I make that same button show/hide a separate image depending on the isOn/isOff state?
Here's my code for the toggle function:
- (IBAction)toggleFunction:(id)sender;
{
if( isOn )
{
[self stopFunction: (NSButton *)sender];
isOn = NO;
}
else
{
[self startFunction: (NSButton *)sender];
isOff = YES;
}
}
You should use isOn instead isOff I think in Your else.
Try this:
- (IBAction)toggleFunction:(id)sender;
{
if( isOn == YES )
{
[self stopFunction: sender];
isOn = NO;
}
else
{
[self startFunction: sender];
isOn = YES;
}
}
** If this not working, say what's wrong. And also try NSLog Your functions to ensure that its called.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.