在 Xcode 4.5 中启动了 Cocos2D 2.1 模板(没有物理引擎),针对 iOS 6 和 iPad。在 CDAudioManager.m 文件中,以下代码...
AVAudioSession* session = [AVAudioSession sharedInstance];
session.delegate = self; // Which is what is automatically generated by the template.
...生成以下警告...
"delegate deprecated: first deprecated in iOS 6"
因此,我查看了苹果开发人员文档,它在“委托”下写道:“在 iOS 6.0 中已弃用。请改用此类的通知部分中描述的通知。”
http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioSession_ClassReference/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instp/AVAudioSession/delegate http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioSession_ClassReference/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instp/AVAudioSession/delegate
问题是,在我看来,我们要做的就是将 AVAudioSession 的委托设置为 CDAudioManager 实例本身(请原谅我缺乏经验)。通知如何实现这一目标?或者我对上面代码的目标是错误的?
您遇到的错误是在这段代码中
AVAudioSession* session = [AVAudioSession sharedInstance];
session.delegate = self;// <-------- DEPRECATED IN IOS 6.0
要消除警告,请将这两行更改为:
[[AVAudioSession sharedInstance] setActive:YES error:nil];
希望这可以帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)