I'm having 5 ViewControllers in each of that i have to display iAd,so that i have to implement iAd code in each ViewControllers. Instead of that if i create set of common code in AppDelegate means i can just call that code wherever i need iAd to be displayed.
If anyone has implemented this iAd concept means help me to get out of this issue. Thanks in Advance.
Just create a Pointer to iAD in APP delegate.
.h:
@property (strong, nonatomic) ADBannerView *UIiAD;
.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIiAD = [[ADBannerView alloc] init];
return YES;
}
Then in your ViewControllers do this:
.h:
@property (strong, nonatomic) ADBannerView *UIiAD;
.m:
- (AppDelegate *) appdelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
- (void) viewWillAppear:(BOOL)animated {
UIiAD = [[self appdelegate] UIiAD];
UIiAD.delegate=self;
// CODE to correct the layout
}
- (void) viewWillDisappear:(BOOL)animated{
UIiAD.delegate=nil;
UIiAD=nil;
[UIiAD removeFromSuperview];
}
Do this for all the view controllers with appropriate code to redesign the layout!
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