【问题标题】:Audio playback code broke with new version of Xcode新版本的 Xcode 破坏了音频播放代码
【发布时间】: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);

}

【问题讨论】:

    标签: ios iphone xcode audio


    【解决方案1】:

    我在其他讨论中找到了解释。显然模拟器无法正常工作。 我找到了解决方案,只需下载 Xcode 5.1.1 即可完成我的项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-21
      • 1970-01-01
      • 2014-01-08
      • 1970-01-01
      • 2011-09-03
      相关资源
      最近更新 更多