【问题标题】:NSWindowController El Capitan Compatible?NSWindowController El Capitan 兼容吗?
【发布时间】:2015-10-26 21:00:18
【问题描述】:

我正在尝试在 El Capitan 上使用 xCode 7.0.1 构建我的项目。之前 NSWindowController 一直致力于显示我们的闪屏窗口,但是自从升级到 El Capitan 以测试我们的插件兼容性后,没有显示任何窗口。

这是我用来显示启动画面的代码(在以前的 OS X 中运行良好):

pcim_splashcontroller * splash = [[pcim_splashcontroller alloc] initWithWindowNibName:@"pcim_splash"];
[[splash window] center];

// Slight time delay here...

[splash close];
[splash release];

pcim_splashcontroller 是这样指定的:

@interface pcim_splashcontroller : NSWindowController
{
    IBOutlet NSTextField *ExpiresLabel;
    IBOutlet NSTextField *CopyrightLabel;
    NSUInteger DaysRemaining;
}

还有其他人在 El Capitan 中成功使用 NSWindowController 吗?最初该插件是在 Yosemite 中构建的,所以我尝试在 El Capitan 中使用最新版本的 xCode 进行重建,但没有运气,所以我想知道这是否是与新 OS X 的兼容性问题。

当我使用调试器单步执行时,没有出现任何错误,并且启动指针似乎分配得当。我也试过添加:

[splash showWindow:nil]

但这似乎也没有帮助。

非常感谢。

【问题讨论】:

  • 看起来完全有效。您可以尝试使用 10.10 SDK 构建它吗?或者您之前用于构建项目的 SDK 是什么? NSWindowController 没有太大变化(只是添加了故事板)
  • 它之前是在 10.10 中构建的。我刚刚在我的 10.10 机器上测试了在 10.11 中构建的副本,并且窗口按预期显示,因此它在 10.11 中正确构建。

标签: xcode7 osx-elcapitan nswindowcontroller


【解决方案1】:

El Capitan 似乎为 NSWindow 提供了某种缓存,可能在主运行循环中进行管理。

试试这个:

[[splash window] center];

[[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1]];

[splash close];

【讨论】:

  • 非常感谢 Antoine Rosset,这是解决我的问题的方法。
  • 是的,我在调用-[NSWindowController close] 时遇到了类似的问题,但窗口没有关闭。我在关闭后添加了一个[[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];,然后它就起作用了!它只发生在 os x 10.11.1
猜你喜欢
  • 1970-01-01
  • 2019-02-03
  • 1970-01-01
  • 1970-01-01
  • 2015-12-28
  • 2015-12-31
  • 2016-01-09
  • 2015-12-20
  • 1970-01-01
相关资源
最近更新 更多