Вопрос

I'm using GoogleAdMobAds in my application to show ads. GoogleAds (somehow) has a reference to flurry ads. (GoogleAdMobAds - version 6.5.0, FluttyAds version 4.3.1.a). ViewController has a tableView that contains GADBannerView. Here is my code.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
    GADAdSize adSize = [self adSizeForOrientation:self.interfaceOrientation];
    self.adview = [[GADBannerView alloc] initWithAdSize:adSize];
    self.adview.adUnitID = ADMOB_APP_KEY;
    self.adview.rootViewController = self;
    self.adview.backgroundColor = [UIColor clearColor];

    GADRequest *request = [GADRequest request];
    request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
    request.gender = kGADGenderMale;
    [request setLocationWithLatitude:[userDefaults doubleForKey:@"lat"]
                           longitude:[userDefaults doubleForKey:@"lng"]
                            accuracy:kCLLocationAccuracyBest];

    self.adview.delegate = self;
    [self.adview loadRequest:request];

So the application crashes when i present uiactionsheet, before

- (void)adViewDidReceiveAd:(GADBannerView *)bannerView

calls. I tried to avoid delegate and rootViewController in GADBannerView before actionsheet present, but all my efforts were in vain.

Это было полезно?

Решение

The problem lays in view controllers hierarchy. I added view controller to window.rootViewController by just addSubview:, after i add [rootViewController addChildViewController:] crash disappears.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top