【问题标题】:How to access pref pane bundle?如何访问首选窗格捆绑包?
【发布时间】:2012-06-24 18:15:42
【问题描述】:

我们如何访问 Mac OS 应用程序的 Pref Pane Bundle ??? 我已将图像和其他资源放在首选项窗格包中,但我无法使用以下方法获取路径: NSString * path = [[NSBundle mainBundle] pathForResource:@"tick" ofType:@"png"];

tick.png 在 NewPrefPane.prefPane 的资源文件夹中的位置

【问题讨论】:

    标签: objective-c nspreferencepane


    【解决方案1】:

    [NSBundle mainBundle]

    返回 System Preferences 应用程序的 NSBundle,因为它是实际运行窗格的应用程序。

    如果您只需要在 NSPreferencePane 类中使用 bundle 方法:

    [self bundle]
    

    在窗格代码的其他地方使用 bundleForClass

    NSString * path = [[NSBundle bundleForClass:[self class] pathForResource:@"tick" ofType:@"png"];
    

    【讨论】:

      猜你喜欢
      • 2013-09-10
      • 2019-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多