Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c ';SoundTap_HDViewController';不实施';AVAudioPlayerDelegate';_Objective C - Fatal编程技术网

Objective c ';SoundTap_HDViewController';不实施';AVAudioPlayerDelegate';

Objective c ';SoundTap_HDViewController';不实施';AVAudioPlayerDelegate';,objective-c,Objective C,我得到这个错误,但我不知道如何修复它 类“SoundTap_HDViewController”未实现“AVAudioPlayerDelegate”协议 有什么帮助吗?如果要遵守协议,需要实现协议所需的方法。AVAudioPlayerDelegate没有必需的方法,因此您可能试图在不添加协议的情况下调用委托方法。你的班级看起来像: @interface SoundTap_HDViewController : NSObject <AVAudioPlayerDelegate> @界面声音

我得到这个错误,但我不知道如何修复它

类“SoundTap_HDViewController”未实现“AVAudioPlayerDelegate”协议


有什么帮助吗?

如果要遵守协议,需要实现协议所需的方法。AVAudioPlayerDelegate没有必需的方法,因此您可能试图在不添加协议的情况下调用委托方法。你的班级看起来像:

@interface SoundTap_HDViewController : NSObject <AVAudioPlayerDelegate>
@界面声音点击\u HDVIEW控制器:NSObject

协议列在和之间,用逗号分隔。

如果要遵守协议,需要实现其所需的方法。AVAudioPlayerDelegate没有必需的方法,因此您可能试图在不添加协议的情况下调用委托方法。你的班级看起来像:

@interface SoundTap_HDViewController : NSObject <AVAudioPlayerDelegate>
@界面声音点击\u HDVIEW控制器:NSObject

协议列在和之间,用逗号分隔。

Hmm,这是正确的代码:-(iAction)playSound{NSString path=[[NSBundle mainBundle]pathForResource:@“wav”类型的“airhorn”;AVAudioPlayer theAudio=[[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path]错误:NULL]“;theAudio.delegate=self;[theAudio play];@Henry.你为什么不试试?”“里面有23个字符-远远少于你评论中的数字:)@Henry.所以你指定“self”作为theAudio的代表,所以不管“self”is应该实现AVAudioPlayerDelegate协议,正如我在回答中指出的那样。对不起,伙计,你必须发布更多的代码。不能用“不工作”来做太多:)@Henry:你可能需要添加#导入AVFoundation.Hmm,这对代码正确吗:-(iAction)playSound{NSString路径=[[NSBundle mainBundle]pathForResource:@“airhorn”的类型:@“wav”];AVAudioPlayer theAudio=[[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path]error:NULL];theAudio.delegate=self;[theAudio play];@Henry.你为什么不试试看呢?“里面有23个字符-远远少于你评论中的数字:)@Henry.所以你在分配“self”“作为音频的代表,所以无论“self”是什么,都应该实现AVAudioPlayerDelegate协议,正如我在回答中所指出的。对不起,伙计,你必须发布更多的代码。不能用“不起作用”来做太多事情。:)@Henry:你可能需要为AVFoundation添加#导入。