我正在制作一个暂停和播放声音的按钮。这是我的编码:
·H:
@interface RootViewController : UIViewController {
}
@property (nonatomic, retain) AVAudioPlayer *theAudio;
-(IBAction)pause;
@end
的.m:
- (void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"MathMusic1" ofType:@"wav"];
self.theAudio = [[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL] autorelease];
theAudio.delegate = self;
[theAudio play];
theAudio.numberOfLoops = -1;
[super viewDidLoad];
}
现在我想按一下按钮来暂停这个,所以这就是编码:(已经在.h中声明)
-(IBAction)pause {
[theAudio pause];
else // expected expression before 'else'
[theAudio play];
}
/错误:'else'之前的预期表达式
答案 0 :(得分:0)
else
没有if
(就在之前),我认为这可能是您代码中的错误。
答案 1 :(得分:0)
您没有if
声明。