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

这里有什么问题?

这是我的 ViewController .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
4

1 回答 1

0

您需要找出错误的来源。您可以单步执行,也可以至少执行以下两个步骤之一:

  1. 将此补丁安装在您的主目录中,以将异常记录到控制台。
  2. 在 Xcode 断点选项卡的底部,按“+”添加新断点,然后选择添加异常断点的选项。(我忘记了显示的确切单词,但它相当明显。)这将在发生异常时导致断点。
于 2013-02-10T14:31:54.737 回答