David73
Aspiring developer
Profile
Posts: 66
Reg: Jan 12, 2013
Texas
660
10/05/13 11:14 AM (12 years ago)

Integrating iAds

I am trying to integrate iAds banner ads into a screen that does not have the Advertisements option built into it. Specifically, I am trying to add it to BT_button_view.m file. Basically, what I need to do is get the [self createAdBannerView]; command to execute. I get a warning that says: Instance method '-createAdBannerView' not found (return type defaults to 'id') I am obviously missing something, but I have not been able to figure out what import, call, or whatever. I have been comparing everything to the BT_screen_customHTML.m file which has it already in it, but haven't been able to find the spcific thing or things I am missing. If anybody with more programming experience could help me out, I would be very grateful. Thanks, Dave
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/05/13 12:43 PM (12 years ago)
at the end of the viewDidLoad Method put [self createAdBannerView]; and then at the end of viewWillAppear method put [self showHideAdView]; simple as that
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/05/13 12:51 PM (12 years ago)
make sure you do that in BT_screen_menuButtons.m not BT_button_view the 2 methods should look like this //viewDidLoad -(void)viewDidLoad{ [BT_debugger showIt:self theMessage:@"viewDidLoad"]; [super viewDidLoad]; //init screen properties [self setDidInit:0]; self.buttonSize = 60; self.buttonPadding = 15; self.buttonLayoutStyle = @"grid"; self.buttonLabelLayoutStyle = @"bottom"; self.buttonLabelFontColor = [UIColor lightGrayColor]; self.buttonLabelFontSize = 13; self.isLoading = FALSE; NSString *stringOpacity = @"1.0"; //appDelegate finalmatchgametester_appDelegate *appDelegate = (finalmatchgametester_appDelegate *)[[UIApplication sharedApplication] delegate]; self.deviceWidth = [appDelegate.rootApp.rootDevice deviceWidth]; self.deviceHeight = [appDelegate.rootApp.rootDevice deviceHeight]; //add the content views..they get resized and updated in layoutScreen method self.myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, deviceWidth, deviceHeight)]; [self.myScrollView setShowsVerticalScrollIndicator:FALSE]; [self.myScrollView setShowsHorizontalScrollIndicator:FALSE]; [self.myScrollView setDelegate:self]; self.myScrollView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth); //prevent scrolling? if([[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"preventAllScrolling" defaultValue:@""] isEqualToString:@"1"]){ [self.myScrollView setScrollEnabled:FALSE]; } //opacity stringOpacity = [NSString stringWithFormat:@".%@", [BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonOpacity" defaultValue:@"100"]]; if([stringOpacity isEqualToString:@".100"]) stringOpacity = @"1.0"; if([stringOpacity isEqualToString:@""]) stringOpacity = @"1.0"; //layout style self.buttonLayoutStyle = [BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonLayoutStyle" defaultValue:@"grid"]; self.buttonLabelLayoutStyle = [BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonLabelLayoutStyle" defaultValue:@"below"]; //font color self.buttonLabelFontColor = [BT_color getColorFromHexString:[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonLabelFontColor" defaultValue:@"#CCCCCC"]]; //convert button opacity self.buttonOpacity = [stringOpacity doubleValue]; //some settings depend on the device size if([appDelegate.rootApp.rootDevice isIPad]){ //use large settings self.buttonSize = [[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonSizeLargeDevice" defaultValue:@"60"] intValue]; self.buttonLabelFontSize = [[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonLabelFontSizeLargeDevice" defaultValue:@"13"] intValue]; self.buttonPadding = [[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonPaddingLargeDevice" defaultValue:@"15"] intValue]; }else{ //use small settings self.buttonSize = [[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonSizeSmallDevice" defaultValue:@"60"] intValue]; self.buttonLabelFontSize = [[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonLabelFontSizeSmallDevice" defaultValue:@"13"] intValue]; self.buttonPadding = [[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"buttonPaddingSmallDevice" defaultValue:@"15"] intValue]; } //add the scrollview [self.view addSubview:myScrollView]; [self createAdBannerView]; }
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/05/13 12:52 PM (12 years ago)
and //view will appear -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [BT_debugger showIt:self theMessage:@"viewWillAppear"]; //flag this as the current screen finalmatchgametester_appDelegate *appDelegate = (finalmatchgametester_appDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.rootApp.currentScreenData = self.screenData; //setup navigation bar and background [BT_viewUtilities configureBackgroundAndNavBar:self theScreenData:[self screenData]]; //if we have not yet inited data.. if(self.didInit == 0){ //get data [self performSelector:(@selector(loadData)) withObject:nil afterDelay:0.1]; //flag [self setDidInit:1]; }else{ [self layoutScreen]; } [self showHideAdView]; }
 
David73
Aspiring developer
Profile
Posts: 66
Reg: Jan 12, 2013
Texas
660
like
10/05/13 12:58 PM (12 years ago)
What does the [self showHideAdView]; command do?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/05/13 01:05 PM (12 years ago)
viewdidload method is fired once only so that method creates the little frame and bangs an add in when the app moves screen the view controller gets rid of the ad previously so viewwillappear shows everytime the view appears filling the add back up again very time it appears also sometimes adds don't fire so it gives it a kick up the backside when it returns lol That's how I understand it anyway and it works
 
David73
Aspiring developer
Profile
Posts: 66
Reg: Jan 12, 2013
Texas
660
like
10/05/13 01:11 PM (12 years ago)
Thanks. I am trying to learn about coding as much as I can so I can make changes like this.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
10/05/13 01:14 PM (12 years ago)
no probs you'll pick it up. I'm no professional coder but I've come up with some awesome stuff
 
Gledy
Aspiring developer
Profile
Posts: 111
Reg: Feb 25, 2013
Fleet, UK
3,260
like
12/11/13 07:25 AM (12 years ago)
Hi, Ive just done this on my Menu Button page, thanks for the info. I am just wondering, would you have to add "includeAds": "1" on the control panel from the screen in the Json Screen data or not? Thanks
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.