Skip to content
Browse files

iAd added

  • Loading branch information...
1 parent 3d0120a commit a1fa23fba15e626b237cf17413e4845d420cee80 @sirnicolaz committed with Nicola Miotto Nov 10, 2010
View
4 SpeakTweet.xcodeproj/project.pbxproj
@@ -176,6 +176,7 @@
D3D7CD1A12541DC400ECC114 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D3D7CD1912541DC400ECC114 /* main.m */; };
D3D8EDE21257A39D009FE482 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D8EDE11257A39D009FE482 /* AVFoundation.framework */; };
D70AB4231248EF2E0027DDC5 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D70AB4221248EF2E0027DDC5 /* QuartzCore.framework */; };
+ D73B5E69128AC5B50066A351 /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73B5E68128AC5B50066A351 /* iAd.framework */; };
D7BB379A125677BC00C0F155 /* FliteWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = D7BB3799125677BC00C0F155 /* FliteWrapper.m */; };
F1474FE70FD3F486007D9F4C /* UICPrototypeTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F1474FD40FD3F486007D9F4C /* UICPrototypeTableCell.m */; };
F1474FE80FD3F486007D9F4C /* UICPrototypeTableCellSelect.m in Sources */ = {isa = PBXBuildFile; fileRef = F1474FD60FD3F486007D9F4C /* UICPrototypeTableCellSelect.m */; };
@@ -469,6 +470,7 @@
D3D8EDE11257A39D009FE482 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
D704E52912476195005BBFAD /* twitter_apikeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = twitter_apikeys.h; path = ../OAuthConsumer/twitter_apikeys.h; sourceTree = "<group>"; };
D70AB4221248EF2E0027DDC5 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ D73B5E68128AC5B50066A351 /* iAd.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = iAd.framework; path = System/Library/Frameworks/iAd.framework; sourceTree = SDKROOT; };
D7BB3798125677BC00C0F155 /* FliteWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FliteWrapper.h; sourceTree = "<group>"; };
D7BB3799125677BC00C0F155 /* FliteWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FliteWrapper.m; sourceTree = "<group>"; };
F1474FD30FD3F486007D9F4C /* UICPrototypeTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICPrototypeTableCell.h; sourceTree = "<group>"; };
@@ -551,6 +553,7 @@
D350EE06125FCF8100E1770C /* libflite_usenglish.a in Frameworks */,
D350EE07125FCF8100E1770C /* libflite.a in Frameworks */,
D350EE20125FD09D00E1770C /* libflite_cmu_us_rms.a in Frameworks */,
+ D73B5E69128AC5B50066A351 /* iAd.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -609,6 +612,7 @@
D70AB4221248EF2E0027DDC5 /* QuartzCore.framework */,
D335F64B12577AC50032F52F /* libiconv.dylib */,
D3D8EDE11257A39D009FE482 /* AVFoundation.framework */,
+ D73B5E68128AC5B50066A351 /* iAd.framework */,
);
name = Frameworks;
sourceTree = "<group>";
View
15 SpeakTweet/controllers/timeline/TimelineViewController.h
@@ -6,6 +6,9 @@
#import "StatusCell.h"
#import "AccelerometerSensor.h"
#import "Timeline.h"
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+#import <iAd/iAd.h>
+#endif
#define PLAY_BUTTON_HEIGTH 44
@@ -23,7 +26,7 @@
@class TweetPostViewController;
@class EGORefreshTableHeaderView;
-@interface TimelineViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>{
+@interface TimelineViewController : UIViewController <ADBannerViewDelegate, UITableViewDelegate, UITableViewDataSource>{
//ST: play calculating mode
UIActivityIndicatorView *activityView;
UIImageView* overlayLayer;
@@ -82,6 +85,11 @@
// Reloading should really be your tableviews model class
// Putting it here for demo purposes
BOOL _reloading;
+
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+ ADBannerView *adView;
+ BOOL bannerIsVisible;
+ #endif
}
@property (readonly) Timeline *timeline;
@@ -90,6 +98,11 @@
@property(nonatomic, retain) UITableView *tableView;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+@property (nonatomic, retain) IBOutlet ADBannerView *adView;
+@property (nonatomic) BOOL bannerIsVisible;
+#endif
+
@end
@interface TimelineViewController(Accerlerometer) <AccelerometerSensorDelegate>
View
68 SpeakTweet/controllers/timeline/TimelineViewController.m
@@ -19,6 +19,11 @@ @implementation TimelineViewController
@synthesize timeline, tableView;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+@synthesize adView;
+@synthesize bannerIsVisible;
+#endif
+
- (id)init {
[super init];
fliteEngine = [[FliteWrapper alloc] initWithOnFinishDelegate:self whenFinishPlayingExecute:@selector(playTweets)];
@@ -118,8 +123,71 @@ - (void)viewDidLoad {
activityView.hidesWhenStopped = YES;
[overlayLayer addSubview:activityView];
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+ NSLog(@"iAd supportato");
+
+ adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0.0f, 367.0f, 0.0f, 0.0f)];
+ adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
+ [self.view addSubview:adView];
+ self.adView.delegate = self;
+ self.bannerIsVisible = NO;
+
+ #else
+ NSLog(@"iAd non supportato");
+ #endif
+
+
}
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+- (void) bannerViewDidLoadAd:(ADBannerView *)banner {
+
+ NSLog(@"iAd banner caricato");
+
+ if (!self.bannerIsVisible) {
+ [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
+ banner.frame = CGRectOffset(banner.frame, 0, -50.0f);
+ //banner.frame = CGRectMake(0, 50, 320, 480);
+ [UIView commitAnimations];
+ self.bannerIsVisible = YES;
+
+ }
+
+}
+#endif
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
+-(BOOL) bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave{
+ NSLog(@"[iAd]: An action was started from the banner. Application will quit: %d", willLeave);
+ return YES;
+}
+#endif
+
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
+-(void) bannerViewActionDidFinish:(ADBannerView *)banner{
+
+}
+#endif
+
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
+-(void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
+ NSLog(@"Impossibile caricare il banner, error: %@", error);
+ if(self.bannerIsVisible){
+ [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
+ banner.frame = CGRectOffset(banner.frame, 0, 50.0f);
+ [UIView commitAnimations];
+ self.bannerIsVisible = NO;
+
+ }
+}
+#endif
+
+
- (void)viewWillAppear:(BOOL)animated {
NSIndexPath *tableSelection = [self.tableView indexPathForSelectedRow];
[self.tableView deselectRowAtIndexPath:tableSelection animated:NO];
View
3 SpeakTweet/controllers/timeline/TimelineViewControllerView.m
@@ -390,10 +390,9 @@ -(void) startActivityIndicator {
}
UITableViewCell* cellToNotCover = [self.tableView cellForRowAtIndexPath:cellIndexPath];
-
[self.view addSubview:overlayLayer];
[self displayLayer:TRUE toHeight:cellToNotCover.bounds.size.height];
-
+ [self.view bringSubviewToFront:self.adView];
//ST: ActivityIndicator stuff...
[activityView startAnimating];

0 comments on commit a1fa23f

Please sign in to comment.
Something went wrong with that request. Please try again.