gpt4 book ai didi

iphone - 无法播放没有错误的声音

转载 作者:行者123 更新时间:2023-12-03 02:19:56 25 4
gpt4 key购买 nike

我一直在寻找解决此问题的方法。我已经正确设置了带有声音文件的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

最佳答案

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

  • 在您的主目录中安装this patch,以将异常记录到控制台。
  • 在“Xcode断点”选项卡的底部,按“+”添加新的断点,然后选择添加异常断点的选项。 (我忘记了显示的确切字眼,但是这很明显。)当发生异常时,这将导致断点。
  • 关于iphone - 无法播放没有错误的声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14798322/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com