Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #import "ViewController.h"
  2. #import "Intro.h"
  3. #import "PurchasedViewController.h"
  4. #import <iAd/iAd.h>
  5. #import "InAppManager.h"
  6.  
  7. @implementation ViewController
  8.  
  9. - (void)viewDidLoad {
  10.  
  11. [super viewDidLoad];
  12.  
  13. [[NSNotificationCenter defaultCenter] addObserver:self
  14. selector:@selector(reload)
  15. name:@"reloadIntro"
  16. object:nil];
  17.  
  18. // Configure the view.
  19. SKView * skView = (SKView *)self.view;
  20.  
  21.  
  22. // Create and configure the scene.
  23. SKScene *scene = [Intro sceneWithSize:skView.bounds.size];
  24. scene.scaleMode = SKSceneScaleModeAspectFill;
  25.  
  26.  
  27. // Present the scene
  28. [skView presentScene:scene];
  29. }
  30.  
  31. -(void)reload {
  32. // Reload the View/Scene to remove iAds
  33. .....
  34. }
  35.  
  36. - (void)viewDidAppear:(BOOL)animated {
  37.  
  38. [super viewDidAppear:animated];
  39.  
  40. //Display iAds
  41. if ( [[InAppManager sharedManager] isFeature1PurchasedAlready] == FALSE) {
  42. NSLog(@"iAds are showing");
  43. ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 480, 320, 50)];
  44. [self.view addSubview:adView];
  45. }
  46.  
  47. //Remove iAds
  48. else if ( [[InAppManager sharedManager] isFeature1PurchasedAlready] == TRUE) {
  49.  
  50. NSLog(@"iAds have been removed");
  51. ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 480, 320, 50)];
  52. adView.hidden = YES;
  53. [adView removeFromSuperview];
  54. }
  55. }
  56.  
  57. -(void) unlockProduct1 {
  58.  
  59. if ( [[InAppManager sharedManager] isFeature1PurchasedAlready] == NO) {
  60. NSLog(@"Product 1 was not bought yet");
  61. [buyProduct1Button setBackgroundImage:[UIImage imageNamed:@"Remove_Ads"] forState:UIControlStateNormal];
  62. }
  63.  
  64. else {
  65. NSLog(@"Product 1 WAS bought");
  66. [buyProduct1Button setBackgroundImage:[UIImage imageNamed:@"Purchased"] forState:UIControlStateNormal];
  67.  
  68. // Sending Notification to ViewController.m
  69. NSLog(@"Did Send notification reloadIntro");
  70. [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadIntro" object:nil];
  71. }
  72. }
  73.  
  74. - (IBAction)dismissPurchasedVC:(UIButton *)sender {
  75. [self dismissModalViewControllerAnimated:YES];
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement