使用 CGDisplay 显示窗口时,文本字段显示为不可编辑
我正在制作一个应用程序,其中:
- 当用户选择显示菜单选项时 ->该窗口显示在整个屏幕上,
- 当用户选择隐藏菜单选项时 - >整个屏幕上可见的窗口将被隐藏。
问题是——
当我执行步骤 1 然后执行步骤时 第2步然后第1步,窗口没有 与第一次出现时一样 时间。
谁能建议我,我该如何解决?
以下是代码部分:
- (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 块下方。使用的代码是-
- (IBAction)displayMenuAction:(id)sender
{
if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display!" );
}
[window makeKeyAndOrderFront:nil];
[window setLevel:CGShieldingWindowLevel()];
}
但我开始面临一个新问题:
当我执行步骤 1 然后执行步骤时 第 2 步然后第 1 步,窗口上的文本字段是 显示为不可编辑。我尝试设置 它们在代码中是可编辑的,但事实并非如此 工作。
请建议。
I am making an application in which:
- when user selects display menu option -> the window is displayed over whole screen and
- when user selects hide menu option - >the window which was visible over whole screen gets hidden.
Problem is -
When I am performing step 1 then step
2nd then step 1, the window does not
appear as it appeared for the first
time.
Can anyone suggest me, how can I resolve it?
Below is the part of code:
- (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()];
}
Edit:
The problem is resolved when I placed the code line: [window makeKeyAndOrderFront:nil]; below the if block in displayMenuAction. The code used is-
- (IBAction)displayMenuAction:(id)sender
{
if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the main display!" );
}
[window makeKeyAndOrderFront:nil];
[window setLevel:CGShieldingWindowLevel()];
}
But I have started facing a new problem:
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.
Please suggest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
窗口是在笔尖中定义的吗?如果是这样,“关闭时释放”复选框是否处于活动状态?如果是,当窗口关闭时,它将被释放。
Is the window defined in a nib? If so, is the "Release when closed" checkbox active? If it is, when the window is closed it will be deallocated.