gpt4 book ai didi

objective-c - 使用 CGDisplay 显示窗口时,文本字段显示为不可编辑

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

我正在制作一个应用程序,其中:

  1. 当用户选择显示菜单选项时 -> 窗口将显示在整个屏幕上并且
  2. 当用户选择隐藏菜单选项时 ->整个屏幕上可见的窗口将被隐藏。

问题是 -

When I am performing step 1 then step 2nd then step 1, the window does not appear as it appeared for the first time.

谁能建议我,我该如何解决它?

下面是部分代码:

- (IBAction)hideMenuAction:(id)sender
{
[window orderOut:nil];
if (CGDisplayRelease( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't release the main display!" );
}
}

- (IBAction)displayMenuAction:(id)sender
{
[window makeKeyAndOrderFront:nil];
if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display!" );
}
[window setLevel:CGShieldingWindowLevel()];
}
<小时/>

编辑:

当我放置代码行时,问题得到解决:[window makeKeyAndOrderFront:nil];在 displayMenuAction 中的 if block 下方。使用的代码是-

- (IBAction)displayMenuAction:(id)sender
{
if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display!" );
}
[window makeKeyAndOrderFront:nil];
[window setLevel:CGShieldingWindowLevel()];
}

但是我开始面临一个新问题:

When I am performing step 1 then step 2nd then step 1, the text fields on window are appearing un-editable. I tried to set them as editable in code but it didn't work.

请提出建议。

最佳答案

窗口是在 Nib 中定义的吗?如果是这样,“关闭时释放”复选框是否处于事件状态?如果是,当窗口关闭时,它将被释放。

关于objective-c - 使用 CGDisplay 显示窗口时,文本字段显示为不可编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6281556/

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