iads与cocos2d集成

时间:2010-11-08 19:56:41

标签: cocos2d-iphone

我正在尝试将iads集成到我的cocos2d应用程序中。在ABCPopAppDelegate文件实现中,我有以下代码:

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
    // wrapper controller class 

    // CC_DIRECTOR_INIT()
    //
    // 1. Initializes an EAGLView with 0-bit depth format, and RGB565 render buffer
    // 2. EAGLView multiple touches: disabled
    // 3. creates a UIWindow, and assign it to the "window" var (it must already be declared)
    // 4. Parents EAGLView to the newly created window
    // 5. Creates Display Link Director
    // 5a. If it fails, it will use an NSTimer director
    // 6. It will try to run at 60 FPS
    // 7. Display FPS: NO
    // 8. Device orientation: Portrait
    // 9. Connects the director to the EAGLView
    CC_DIRECTOR_INIT();

    CCDirector *director = [CCDirector sharedDirector];
    CGSize winSize = [director winSize]; 
    MainViewController *controller = [[MainViewController alloc] init]; 
    controller.view.frame = CGRectMake(0,winSize.height-50 , 320, 50);
    controller.view.hidden = YES;

    controller.bannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];

    //controller.bannerView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
    //controller.bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;

    [controller.bannerView setDelegate:controller]; 

    [controller.view addSubview:controller.bannerView];

我收到以下错误:

"_OBJC_CLASS_$_ADBannerView", referenced from:
这是什么意思?

1 个答案:

答案 0 :(得分:3)

您收到该错误是因为您尚未在XCode上将iADFramework添加到Target。确保将其添加为WEAK参考,以便它不会在运行<的设备上中断4.0 iOS。不要忘记让RootViewController符合ADBannerViewDelegate。

如上所述,我还建议您阅读一个很好的教程。我喜欢这个:

http://xcode4all.wordpress.com/2011/06/10/how-to-add-iad-banner-in-iphone-app/

和另一个:

http://useyourloaf.com/blog/2010/11/27/iad-framework-updates-for-ios-42.html