【发布时间】:2014-10-06 23:04:43
【问题描述】:
首先我必须说,我是 iOS 开发的初学者。我将不胜感激任何帮助。 我编写了一个代码,在触摸某些按钮时播放声音,它在以前的 Xcode 版本中运行良好,但在这个新版本中,没有声音播放。在构建代码期间,没有报告任何错误,当我打开 iPhone 4s 模拟器时,其他一切正常,该模拟器是此代码的目标。请帮忙。
这是我的代码: 文件.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <CoreLocation/CoreLocation.h>
@interface DataViewController : UIViewController <CLLocationManagerDelegate> {
int nob, nof, nod;
CLLocationManager *locationManager;
}
@property (strong, nonatomic) IBOutlet UILabel *maxDistanceLabel;
@property (nonatomic,strong) NSArray *fetchedSettingsArray;
@property (nonatomic,retain) NSNumber *numB;
- (IBAction)forwardB:(id)sender;
- (IBAction)backB:(id)sender;
@property (strong, nonatomic) IBOutlet UILabel *numberB;
@end
file.m(只是需要播放音频的部分)
- (IBAction)forwardB:(id)sender {
nob ++;
NSString *nobStr=[NSString stringWithFormat:@"%d",nob];
[numberB setText:nobStr];
numB=[NSNumber numberWithInt:nob];
//sound at button touch
NSString *effectTitle;
effectTitle =@"Buckklick";
SystemSoundID soundID;
NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"wav"];
NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];
AudioServicesCreateSystemSoundID ((__bridge CFURLRef)soundUrl, &soundID);
AudioServicesPlaySystemSound(soundID);
}
【问题讨论】: