Skip to content

Commit

Permalink
Merge pull request #3064 from vishalduggal/timob-11187
Browse files Browse the repository at this point in the history
[TIMOB-11187] Adview crash
  • Loading branch information
srahim committed Sep 27, 2012
2 parents c787cd4 + 45d9039 commit 5d21b74
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
14 changes: 14 additions & 0 deletions iphone/Classes/TiRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,20 @@ - (void) viewDidDisappear:(BOOL)animated

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
//IOS6. If we are presenting a modal view controller, get the preferred
//presentation orientation from the modal view controller
id<TiUIViewControllerIOS6Support> topmostController = [self topmostViewController];
if (topmostController != self) {
//If I am a modal window then send out orientationFlags property
if ([topmostController isKindOfClass:[UINavigationController class]]) {
UIViewController* topVC = [(UINavigationController *)topmostController topViewController];
if ( topVC != nil && ([topVC isKindOfClass:[TiViewController class]]) ) {
return [self lastValidOrientation];
}
}
//Send out whatever the View Controller supports
return [topmostController preferredInterfaceOrientationForPresentation];
}
return [self lastValidOrientation];
}

Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUIiOSAdView.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#ifdef USE_TI_UIIOSADVIEW

#import "TiUIiOSAdViewProxy.h"
#import <iAd/iAd.h>

@interface TiUIiOSAdView : TiUIView<ADBannerViewDelegate> {
Expand Down
6 changes: 1 addition & 5 deletions iphone/Classes/TiUIiOSAdView.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ - (void)bannerViewDidLoadAd:(ADBannerView *)banner
WARN_IF_BACKGROUND_THREAD_OBJ; //NSNotificationCenter is not threadsafe!
[[NSNotificationCenter defaultCenter] postNotificationName:kTiAnalyticsNotification object:nil userInfo:event];
}
if ([self.proxy _hasListeners:@"load"])
{
NSMutableDictionary *event = [NSMutableDictionary dictionary];
[self.proxy fireEvent:@"load" withObject:event];
}
[(TiUIiOSAdViewProxy*) self.proxy fireLoad:nil];
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
Expand Down
3 changes: 2 additions & 1 deletion iphone/Classes/TiUIiOSAdViewProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
// must be class-available rather than instance-available
+(NSString*)portraitSize;
+(NSString*)landscapeSize;

#pragma mark internal
-(void)fireLoad:(id)unused;
@end

#endif
20 changes: 20 additions & 0 deletions iphone/Classes/TiUIiOSAdViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ +(NSString*)landscapeSize
return @"ADBannerContentSize480x32";
}

-(TiDimension)defaultAutoWidthBehavior:(id)unused
{
return TiDimensionAutoSize;
}
-(TiDimension)defaultAutoHeightBehavior:(id)unused
{
return TiDimensionAutoSize;
}

USE_VIEW_FOR_CONTENT_HEIGHT
USE_VIEW_FOR_CONTENT_WIDTH

Expand Down Expand Up @@ -66,6 +75,17 @@ -(void)setAdSize:(id)arg
[self makeViewPerformSelector:@selector(setAdSize:) withObject:arg createIfNeeded:YES waitUntilDone:NO];
}

-(void)fireLoad:(id)unused
{
if ([self _hasListeners:@"load"])
{
NSMutableDictionary *event = [NSMutableDictionary dictionary];
[self fireEvent:@"load" withObject:event];
}

[self contentsWillChange];
}

@end

#endif

0 comments on commit 5d21b74

Please sign in to comment.