ios - 'JSQSystemSoundPlayer' 错误没有可见的@interface

标签 ios objective-c swift jsqmessagesviewcontroller

我刚刚添加了文件:

JSQSystemSoundPlayer.h
JSQSystemSoundPlayer.m

进入我的项目,它出现了下一个错误:

No visible @interface for 'JSQSystemSoundPlayer' declares the selector 'playAlertSoundWithFilename:fileExtension:'

我搜索了很多,但找不到解决方案。谁知道怎么解决?

最佳答案

这是方法的声明

- (void)playAlertSoundWithFilename:(NSString *)filename
                 fileExtension:(NSString *)fileExtension
                    completion:(nullable JSQSystemSoundPlayerCompletionBlock)completionBlock;

你缺少完成 block ,没有只有两个参数的方法

这里是如何使用它的例子

[[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:@"mySoundFile"
                                             fileExtension:kJSQSystemSoundTypeAIF
                                                completion:^{
                                                  // completion block code
                                                }];

编辑:根据评论

如果您查看 playSoundWithFilename: fileExtension: completion: 的声明你会发现的方法

@param completionBlock A block called after the sound has stopped playing.

这意味着在声音停止播放后做任何您想做的事情。如果您不想做任何事情,那么您可以传递 nil 或如上所述的空 block

关于ios - 'JSQSystemSoundPlayer' 错误没有可见的@interface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31831870/

相关文章:

ios - 编程中 "Fast script call and stripping"是什么意思

ios - 使用 Twilio 无法通过麦克风听到声音

objective-c - Objective-C 中的类属性列表

ios - NSMutableArray writeToUrl

ios - 旧设备上的异步 DispatchQoS.QoSClass.background

ios - 在 viewWillDisappear 中将 FetchedResultsController 设置为 nil 后出现错误

swift - 通过 Collection View cell 在 ViewController 之间传递数据

ios - 如何根据暗/亮模式设置默认标签颜色(在 Swift 中)

iOS Flicker API 只需上传一张公共(public)图片?

ios - 在应用程序进入后台之前执行操作