【问题标题】:No known class method for selector notificationCenterVibrancyEffect iOS 8选择器notificationCenterVibrancyEffect iOS 8没有已知的类方法
【发布时间】:2014-09-22 06:51:24
【问题描述】:

我正在尝试使用UIBlurEffectUIVibrancyEffect 进行查看。

Apple docs here 声称“notificationCenterVibrancyEffect”,但即使在我的课程中导入 UIKit 后,它也会抛出 No known class method for selector notificationCenterVibrancyEffect

代码看起来像这样,其他所有类方法都可以正常解析:

UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect notificationCenterVibrancyEffect];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];

【问题讨论】:

  • 您使用的是什么版本的 iOS?这被记录在“iOS 8.0 或更高版本”中。
  • 抱歉,这很清楚 - 是的,所有目标都设置为 iOS 8
  • 你在和 Swift 交互吗?文档只显示了 Obj-C 可用的方法,这很奇怪。
  • 不,不是 Swift——真正奇怪的是我看到有人在 Swift 中使用它写了一个要点:-/

标签: objective-c ios8 uiblureffect


【解决方案1】:

这仅适用于“今日”扩展程序。如果您在“Today”类扩展的项目中创建一个新目标并将您的代码添加到视图控制器,它将构建良好。

方法+ (UIVibrancyEffect *)notificationCenterVibrancyEffect;在名为NotificationCenter的类UIVibrancyEffect的类别中声明,并在NotificationCenter框架中声明在名为NCWidgetProviding.h的头文件中

尝试:#import <NotificationCenter/NotificationCenter.h> 在您的视图控制器中,我能够以这种方式使用您的代码构建示例项目。

【讨论】:

    猜你喜欢
    • 2013-11-21
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多