【问题标题】:[GADSlot state]: unrecognized selector sent to instance in iphone[GADSlot 状态]:无法识别的选择器发送到 iphone 中的实例
【发布时间】:2014-04-21 10:05:57
【问题描述】:

我是 iOS 开发新手。

我正在尝试在我的 phonegap 应用中在 iOS 中实现 admob 广告,所以我用谷歌搜索并找到了 somveadmob without plugin

完成所有程序后, 我收到一个错误 MyApp[2388:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADSlot state]: unrecognized selector sent to instance 0x10415920'**

所以我在谷歌上搜索并发现我必须更改其他链接器标志。 (-ObjC)here

我已经尝试过了,但它不起作用。

我收到此错误。

这个解决方案也不适合我。 [GADSlot state]: unrecognized selector sent to instance

2014-04-21 13:04:41.252 MyApp[2388:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADSlot state]: unrecognized selector sent to instance 0x10415920'
*** First throw call stack:
(
 0   CoreFoundation                      0x038a85e4 __exceptionPreprocess + 180
 1   libobjc.A.dylib                     0x02acb8b6 objc_exception_throw + 44
 2   CoreFoundation                      0x03945903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
 3   CoreFoundation                      0x0389890b ___forwarding___ + 1019
 4   CoreFoundation                      0x038984ee _CF_forwarding_prep_0 + 14
 5   MyApp                            0x0001a01e -[GADSlot isMakingRequest] + 36
 6   MyApp                            0x00019c7d -[GADSlot setAdType:andReloadRequest:] + 334
 7   MyApp                            0x00018a5e -[GADBannerView setAdSize:andReload:] + 512
 8   MyApp                            0x00019052 -[GADBannerView setAdSize:] + 62
 9   MyApp                            0x00019381 -[GADBannerView initWithAdSize:] + 171
 10  MyApp                            0x00003e17 -[MainViewController viewDidLoad] + 118
 11  UIKit                               0x0021c318 -[UIViewController loadViewIfRequired] + 696
 12  UIKit                               0x0021c5b4 -[UIViewController view] + 35
 13  MyApp                            0x00002997 -[AppDelegate application:didFinishLaunchingWithOptions:] + 763
 14  UIKit                               0x00102355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
 15  UIKit                               0x00102b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
 16  UIKit                               0x001073a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
 17  UIKit                               0x0011b87c -[UIApplication handleEvent:withNewEvent:] + 3447
 18  UIKit                               0x0011bde9 -[UIApplication sendEvent:] + 85
 19  UIKit                               0x00109025 _UIApplicationHandleEvent + 736
 20  GraphicsServices                    0x038062f6 _PurpleEventCallback + 776
 21  GraphicsServices                    0x03805e01 PurpleEventCallback + 46
 22  CoreFoundation                      0x03823d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
 23  CoreFoundation                      0x03823a9b __CFRunLoopDoSource1 + 523
 24  CoreFoundation                      0x0384e77c __CFRunLoopRun + 2156
 25  CoreFoundation                      0x0384dac3 CFRunLoopRunSpecific + 467
 26  CoreFoundation                      0x0384d8db CFRunLoopRunInMode + 123
 27  UIKit                               0x00106add -[UIApplication _run] + 840
 28  UIKit                               0x00108d3b UIApplicationMain + 1225
 29  MyApp                            0x000025fd main + 95
 30  MyApp                            0x00002595 start + 53
 )
libc++abi.dylib: terminating with uncaught exception of type NSException

请帮帮我。

ma​​in.m

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");//It highlight this line when exception accoure.
    [pool release];
    return retVal;
}

MainViewController.m

- (void) viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    bannerView_ = [[GADBannerView alloc]initWithAdSize:kGADAdSizeSmartBannerPortrait];

    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;
    CGFloat screenXPos = (screenWidth/2);
    CGFloat screenYPos = screenHeight - kGADAdSizeBanner.size.height;
    [bannerView_ setCenter:CGPointMake(screenXPos, screenYPos)];
    bannerView_.adUnitID = MY_BANNER_UNIT_ID;
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];
    GADRequest *request = [GADRequest request];
    request.testing = NO;
    [bannerView_ loadRequest:request];

}

【问题讨论】:

  • @Visput :- 因为我已经添加了这个问题,它不适合我。
  • 您的 MainViewController 设置 GADBannerView 不正确。所以它使用了一个 GADSlot 对象,应该使用其他对象类(识别选择器“状态”的对象类)。如果您有 GADBannerView 的来源,请检查它并查看对象引用的来源。
  • 正如我所说,我对 ios devlopment 完全陌生,但如果你能帮助我,我可以发布 GADBannerView 的代码
  • 你有多少个目标?您确定您更改了正确的设置吗?

标签: ios objective-c unrecognized-selector


【解决方案1】:

我认为,GADBannerView 设置不正确。如果您有 GADBannerView 的来源,请检查它并查看对象引用的来源。U 应该尝试在该方向解决此错误。

还要检查您的 admob 版本,因为 GDBBannerview 是 Admob 的一部分,这可能来自该代码。 或者尝试使用其他(较旧或较新版本)的 admob api。

【讨论】:

  • 你能解释一下我该怎么做吗?因为我刚接触 iOS 开发,所以我不知道该怎么做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-28
  • 2012-07-24
相关资源
最近更新 更多