2013-02-10 116 views
0

我一直在試圖找到解決此問題的方法。我已經正確設置了帶有聲音文件的AudioToolbox框架,沒有任何錯誤。它編譯並運行正常,但是當我嘗試點擊按鈕播放聲音時,我在一個名爲main.m的文件中看到一個醜陋的綠色突出顯示。 這裏是main.m文件時,它給我帶來了高達試圖播放聲音後:無法播放聲音無錯

#import <UIKit/UIKit.h> 
#import "AppDelegate.h" 

int main(int argc, char *argv[]) { 
    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
    } 
} 

return UIApplicationMain線,這也正是綠色顯示。它說Thread 1: Signal SIGABRT

這裏有什麼問題?

這裏是我的視圖控制器的.m和.h文件:

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 
@synthesize bannerIsVisible; 


-(void)bannerViewDidLoadAd:(ADBannerView *)banner { 
if (!self.bannerIsVisible) { 

    [UIView beginAnimations:@"animateAdBanner" context:NULL]; 
    banner.frame = CGRectOffset(banner.frame, 0, -50.0f); 
    [UIView commitAnimations]; 
    self.bannerIsVisible = YES; 
} 
} 

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error { 
if (self.bannerIsVisible) { 
    [UIView beginAnimations:@"animateAdBannerOff" context:NULL]; 
    banner.frame = CGRectOffset(banner.frame, 0, 50.0f); 
    [UIView commitAnimations]; 
    self.bannerIsVisible = NO; 
} 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

adView = [[ADBannerView alloc] initWithFrame:CGRectZero]; 
adView.frame = CGRectOffset(adView.frame, 0, 460.0f); 
adView.requiredContentSizeIdentifiers = [NSSet  setWithObject:ADBannerContentSizeIdentifierPortrait]; 
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 
[self.view addSubview:adView]; 
adView.delegate=self; 
self.bannerIsVisible=NO; 

} 

- (void)didReceiveMemoryWarning 


{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

- (IBAction)cstring:(id)sender { 
CFBundleRef mainBundle = CFBundleGetMainBundle(); 
CFURLRef soundFileURLRef; 
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"CString", CFSTR ("caf"), NULL); 
UInt32 soundID; 
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
AudioServicesPlaySystemSound(soundID); 
} 
@end 

現在我的.h:

#import <iAd/iAd.h> 
#import <UIKit/UIKit.h> 
#import <AudioToolbox/AudioToolbox.h> 
#import <iAd/ADBannerView_Deprecated.h> 
#import <Foundation/Foundation.h> 
#import <AVFoundation/AVFoundation.h> 

@interface ViewController : UIViewController <ADBannerViewDelegate> { 


ADBannerView *adView; 
BOOL bannerIsVisible; 

} 

@property (nonatomic, assign) BOOL bannerIsVisible; 


- (IBAction)cstring:(id)sender; 












@end 
+0

這意味着發生了一個objective-c異常。此文件不是問題所在,請告訴我們播放聲音的位置。 – 2013-02-10 13:57:04

+0

@j這個問題與Xcode無關。 Xcode是你正在編程的IDE,它似乎工作得很好。 – dandan78 2013-02-10 13:59:51

+0

我已將.h和.m文件添加到主要問題 – 2013-02-10 14:13:04

回答

0

你需要找出錯誤的根源。您可以單步執行,或者您可以執行以下兩個步驟中的至少一個:

  1. 在您的main中安裝this patch以將異常記錄到控制檯。
  2. 在Xcode斷點選項卡的底部,按下「+」添加新的斷點,然後選擇添加異常斷點的選項。 (我忘記了顯示的確切單詞,但它非常明顯。)這將在發生異常時導致斷點。