Created
January 4, 2011 15:28
-
-
Save jedisct1/764908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import "LDMAdit.h" | |
@interface SimpleAdView : UIView { | |
NSString *wantedPageId; | |
LDMAdit *ldmAdit; | |
} | |
- (void) switchToEstatGroup: (NSString *) estatGroup andPage: (NSString *) estatPage; | |
@end | |
@implementation SimpleAdView | |
- (void) load: (NSString *) pageId { | |
[ldmAdit removeFromSuperview]; | |
ldmAdit = [[LDMAdit alloc] initWithBannerType: extendedBanner campaignId: pageId autoRefresh: FALSE]; | |
[ldmAdit initConfig: LDMADIT_SERVER_PRODUCTION showLog: YES alertBeforeShowingAd: NO]; | |
wantedPageId = pageId; | |
#if BYPASS_LDMADIT | |
[self setBackgroundColor: [UIColor redColor]]; | |
#else | |
[self addSubview: ldmAdit]; | |
[ldmAdit release]; | |
[ldmAdit showAd]; | |
#endif | |
} | |
- (void) switchToEstatGroup: (NSString *) estatGroup andPage: (NSString *) estatPage { | |
#if DEBUG | |
NSString *pageId = @"4510"; | |
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: | |
@"4510", @"Home", | |
nil]; | |
#else | |
NSString *pageId = @"2439"; | |
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: | |
@"2439", @"Home", | |
@"2756", @"deconnexion", | |
@"2757", @"Mon_actu", | |
@"2758", @"Upload", | |
@"2759", @"Chat", | |
@"2760", @"admin_blog", | |
@"2761", @"profils_admin", | |
@"2762", @"friends", | |
@"2763", @"Messagerie", | |
@"2764", @"Blog", | |
@"2765", @"profils", | |
@"2766", @"Account", | |
@"2767", @"gifts", | |
@"2768", @"search", | |
@"2769", @"error", | |
nil]; | |
#endif | |
for (NSString *foundGroup in dict) { | |
if ([foundGroup compare: estatGroup options: NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch] == 0) { | |
pageId = [dict objectForKey: foundGroup]; | |
break; | |
} | |
} | |
[dict release]; | |
[self load: pageId]; | |
} | |
- (id)initWithFrame:(CGRect)frame { | |
if (!(self = [super initWithFrame: frame])) { | |
return nil; | |
} | |
self.opaque = YES; | |
self.backgroundColor = [UIColor clearColor]; | |
wantedPageId = nil; | |
ldmAdit = nil; | |
return self; | |
} | |
- (void)drawRect:(CGRect)rect { | |
} | |
- (void)dealloc { | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this changes :
change load function line 16 by
ldmAdit = [[LDMAdit alloc] initWithBannerType: extendedBanner campaignId: pageId autoRefresh: FALSE];
[self addSubview: ldmAdit];
//you need to add sudview before initialisize adit
[ldmAdit initConfig: LDMADIT_SERVER_PRODUCTION showLog: YES alertBeforeShowingAd: NO];
wantedPageId = pageId;
[ldmAdit showAd];
}
change line 65 by
[ldmAdit showAd]; //to show an ad, you just call showad
add line 87
[ldmAdit dealloc];