5
我試圖iAd的融入是Cocos2d-X項目:如何在描述解決 「成員訪問到類型不完全」 錯誤
#import <Foundation/Foundation.h>
#import <iAd/iAd.h>
@class RootViewController;
@interface AdBanner : NSObject<ADBannerViewDelegate>
{
UIWindow* window;
RootViewController* rootViewController;
ADBannerView* adBannerView;
bool adBannerViewIsVisible;
}
AdBanner.mm
http://becomingindiedev.blogspot.com.es/2015/02/integrating-iad-in-cocos2d-x-v3x.htmlAdBanner.h
@implementation AdBanner
-(id)init
{
if(self=[super init])
{
adBannerViewIsVisible = YES;
rootViewController =
(RootViewController*) [[[UIApplication sharedApplication] keyWindow] rootViewController];
window = [[UIApplication sharedApplication] keyWindow];
[self createAdBannerView];
}
return self;
}
-(void)layoutAnimated:(BOOL)animated
{
CGRect bannerFrame = adBannerView.frame;
//Has the banner an advestiment?
if (adBannerView.bannerLoaded && adBannerViewIsVisible)
{
NSLog(@"Banner has advertisement");
bannerFrame.origin.y = window.bounds.size.height - bannerFrame.size.height;
} else
{
NSLog(@"Banner has NO advertisement");
//if no advertisement loaded, move it offscreen
bannerFrame.origin.y = window.bounds.size.height;
}
[UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{
[rootViewController.view layoutIfNeeded]; //Member access into incomplete type "RootViewController"
adBannerView.frame = bannerFrame;
}];
}
@end
在AdBanner.mm底部的行給出了錯誤:
[rootViewController.view layoutIfNeeded]; //Member access into incomplete type "RootViewController"
我該如何解決?
'rootViewController'看起來像一個指針,嘗試' - >'? – user3528438
這是objective-C++代碼。 –
它在vsoftco編輯之前被標記爲C++ ...... – user3528438