2013-08-06 150 views
0

當我啓動我的應用程序生成成功,但是當幾乎就在開始的時候崩潰,並強調以下幾點:線程1個信號SIGABRT錯誤

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文件,我使用的代碼是從谷歌橫幅上的演示應用程序:

@class GADBannerView, GADRequest; 

@interface MainViewController : UIViewController <GADBannerViewDelegate> { 


    GADBannerView *adBanner_; 
} 

@property(nonatomic, strong) GADBannerView *adBanner; 

和我的.m文件還從谷歌演示應用程序:

@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]); 
} 

回答

-1

這是你的問題:

[GADObjectPrivate changeState:]: unrecognized selector sent to instance 

你輸入正確的方法叫什麼名字?這意味着您所調用的方法不存在。更具體地說,GADObjectPrivate類不包含此方法。

調用changeState時的崩潰:之前曾被問過。看到這個問題:

AdMob crashes with [GADObjectPrivate changeState:]: unrecognized selector

+0

「我發現,這是導致錯誤的部分」被右下方指出,「[GADObjectPrivate改變狀態:]:無法識別的選擇發送到實例」 – heinst

+0

那麼,如果這是正確的情況下他說:「在控制檯中的錯誤信息:」 – heinst

+0

當我創建一個新的項目時,鏈接爲我工作,但當我在當前項目中更改它,我收到12錯誤,任何想法? – user2654446