I am developing an application where i have to show iAds in all the pages of my application.. I created a subclass of UIView where i am initializing the the ADBannerView and its delegate methods.
But now if I add it in window in AppDelegate class it is giving me following error at run time "ADBannerView must be part of a view hierarchy managed by a UIViewController"..
I think this mean that I can use ADBanner only in UIViewController's subclass file??
if so then how can I make it global??
Thanks in Advance Shreya
In AppDelegate class you can make a shared object.
- (ADBannerView *) sharedBannerView
{
if (_sharedBannerView == nil)
{
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil)
{
_sharedBannerView = [[classAdBannerView alloc] initWithFrame:CGRectMake(0, 480, 320, 50)];
// pre 4.2 doesn't have the new AdBannerSize constants.
if (&ADBannerContentSizeIdentifierPortrait != NULL)
{
[_sharedBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects:ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]];
}
else
{
[_sharedBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects:ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil]];
}
}
}
((ADBannerView *)_sharedBannerView).backgroundColor = [UIColor whiteColor];
return _sharedBannerView;
}
And add this shared object to the view wherever you need to display iAds. Hope you get it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With