gpt4 book ai didi

macos - XCode IBAction NSButton 显示/隐藏单独的图像?

转载 作者:行者123 更新时间:2023-12-03 17:58:56 25 4
gpt4 key购买 nike

我有一个 IBAction,它充当我的一个功能的切换开关;如何使同一个按钮根据 isOn/isOff 状态显示/隐藏单独的图像?

这是我的切换功能代码:

- (IBAction)toggleFunction:(id)sender;
{
if( isOn )
{
[self stopFunction: (NSButton *)sender];
isOn = NO;
}
else
{
[self startFunction: (NSButton *)sender];
isOff = YES;
}
}

最佳答案

我认为您应该在 Your else 中使用 isOn 而不是 isOff

试试这个:

- (IBAction)toggleFunction:(id)sender;
{
if( isOn == YES )
{
[self stopFunction: sender];
isOn = NO;
}
else
{
[self startFunction: sender];
isOn = YES;
}
}

** 如果这不起作用,请说出问题所在。并且还尝试 NSLog 你的函数以确保其被调用。

关于macos - XCode IBAction NSButton 显示/隐藏单独的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9542110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com