[英]Thread 1 signal sigabrt error
当我启动应用程序时,构建成功,但是在刚开始时几乎崩溃,并突出显示以下内容:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([yes_or_no_AppDelegate class]));
并说:
Thread 1: signal SIGABRT
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([yes_or_no_AppDelegate class]));
}
}
控制台中的错误消息:
[GADObjectPrivate changeState:]: unrecognized selector sent to instance
我发现这是导致错误的部分。 如果删除它,则可以启动该应用程序。
[self.bannerView setRootViewController:self];
但是,当我启动该应用程序时,我没有收到横幅,也没有在控制台中收到错误消息:
Must set the rootViewController property of GADBannerView before calling loadRequest:
这是我的.h文件,我使用的代码来自横幅广告上的Google演示应用程序:
@class GADBannerView, GADRequest;
@interface MainViewController : UIViewController <GADBannerViewDelegate> {
GADBannerView *adBanner_;
}
@property(nonatomic, strong) GADBannerView *adBanner;
和我的.m文件也来自Google演示应用程序:
@synthesize adBanner = adBanner_;
#pragma mark init/dealloc
// Implement viewDidLoad to do additional setup after loading the view,
// typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize the banner at the bottom of the screen.
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.height -
CGSizeFromGADAdSize(kGADAdSizeBanner).height);
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
origin:origin]
;
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
self.adBanner.adUnitID = kSampleAdUnitID;
self.adBanner.delegate = self;
[self.bannerView setRootViewController:self];
[self.view addSubview:self.adBanner];
self.adBanner.center =
CGPointMake(self.view.center.x, self.adBanner.center.y);
[self.adBanner loadRequest:[self createRequest]];
}
- (void)dealloc {
adBanner_.delegate = nil;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
#pragma mark GADRequest generation
// Here we're creating a simple GADRequest and whitelisting the application
// for test ads. You should request test ads during development to avoid
// generating invalid impressions and clicks.
- (GADRequest *)createRequest {
GADRequest *request = [GADRequest request];
// Make the request for a test ad. Put in an identifier for the simulator as
// well as any devices you want to receive test ads.
request.testDevices =
[NSArray arrayWithObjects:
// TODO: Add your device/simulator test identifiers here. They are
// printed to the console when the app is launched.
nil];
return request;
}
#pragma mark GADBannerViewDelegate impl
// We've received an ad successfully.
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(@"Received ad successfully");
}
- (void)adView:(GADBannerView *)view
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
}
这是您的问题:
[GADObjectPrivate changeState:]: unrecognized selector sent to instance
您输入的方法名称正确吗? 这意味着您正在调用的方法不存在。 更具体地说,GADObjectPrivate类不包含此方法。
之前曾问过调用changeState:时发生崩溃。 看到这个问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.