2014-10-06 63 views
1

首先我必須說,我是一個iOS開發的初學者。我將不勝感激任何幫助。 我已經制作了一個代碼,當某些按鈕被觸摸時播放聲音,它在以前的Xcode版本中運行良好,但在這個新的聲音中沒有播放聲音。在構建代碼的過程中,沒有錯誤報告,當我打開iPhone 4s的模擬器時,其他一切都正常工作,其中一個是此代碼的目標。請幫忙。音頻播放代碼打破了新版本的Xcode

這裏是我的代碼: file.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 [email protected]"Buckklick"; 
    SystemSoundID soundID; 
    NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"wav"]; 
    NSURL *soundUrl = [NSURL fileURLWithPath:soundPath]; 
    AudioServicesCreateSystemSoundID ((__bridge CFURLRef)soundUrl, &soundID); 
    AudioServicesPlaySystemSound(soundID); 

} 

回答

0

我發現解釋在其他一些討論。顯然模擬器工作不正常。 我找到了解決方案,只需下載Xcode 5.1.1即可完成我的項目。