This is probably something quite basic. I am trying to implement AdWhirl into my app, which I have done successfully for the technical part. When I load my app, the add loads and then slides down from the top to sit at the bottom of the screen. However, when I rotate the device, the advert uses "precise" locations and moves off screen. When the advert reloads (refreshes every 15 seconds) the advert moves up to the bottom of the screen of the landscape window. Again, when rotating back from landscape, the Advert Aligns it's self in the middle of the page vertically (covering content) until a new advert loads. I have attached a number of photos, in a series showing what happens, all in order and taken at least 10 seconds apart (showing test advert of "Hello").
My code from the Implementation file is included at the end of this post - sorry for not using the code format, just didn't want to put spaces in front of the whole block, and I think it's all relatively relevant. It's also available at the paste bin: http://pastebin.com/mzavbj2L
Sam
Pictures: please be sure to see them in the right order;
IMG_0615.PNG (157.8 KB)
IMG_0616.PNG (105.6 KB)
IMG_0617.PNG (106.1 KB)
IMG_0618.PNG (148.8 KB)
For if you prefer it to a paste bin, I've included the code in it's entirety below:
My code from the Implementation file is included at the end of this post - sorry for not using the code format, just didn't want to put spaces in front of the whole block, and I think it's all relatively relevant. It's also available at the paste bin: http://pastebin.com/mzavbj2L
Sam
Pictures: please be sure to see them in the right order;
IMG_0615.PNG (157.8 KB)
IMG_0616.PNG (105.6 KB)
IMG_0617.PNG (106.1 KB)
IMG_0618.PNG (148.8 KB)
For if you prefer it to a paste bin, I've included the code in it's entirety below:
Code:
//
// SafariViewController.m
// Safari
//
// Created by Samuel B Heather on 02/10/2010.
// Copyright Samuel B Heather 2010. All rights reserved.
//
#import "SafariViewController.h"
#import "Appirater.h"
#import "AdWhirlView.h"
@implementation SafariViewController
-(IBAction)showModalViewController {
InfophoneViewController *tempView = [[InfophoneViewController alloc] initWithNibName:@"InfophoneViewController" bundle:nil];
[self presentModalViewController:tempView animated:true];
[tempView release];
}
-(IBAction)closeText {
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[webAdress text]]]];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
AdWhirlView *adView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.view addSubview:adView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index-phone" ofType:@"html"]isDirectory:NO]]];
//THESE TWO LINES ARE NEEDED FOR MAKING THE LOADING INDICATOR WORK.
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkLoad) userInfo:nil repeats:YES];
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkNotLoad) userInfo:nil repeats:YES];
}
- (void)adWhirlDidReceiveAd:(AdWhirlView *)adView {
[UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:" context:nil];
[UIView setAnimationDuration:0.7];
//move the add to the bottom of the view instead of the top.
CGSize adSize = [adView actualAdSize];
CGRect newFrame = adView.frame;
newFrame.size = adSize;
newFrame.origin.x = (self.view.bounds.size.width - adSize.width)/ 2;
newFrame.origin.y = (self.view.bounds.size.height - adSize.height);
adView.frame = newFrame;
[UIView commitAnimations];
}
/* -(void)didRotate:(NSNotification *)notification{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"An Alert!"
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
} */
-(void)alertView:(UIAlertView *) alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
//OK button 0, option1 =1 option2=2
NSLog(@"%d", buttonIndex);
switch (buttonIndex) {
case 1:
//they liked the game send them to
// app store to review
NSLog(@"We want good reviews, send to app store");
break;
case 2:
// they hated our game don't send
// them to app store, don't ask again
NSLog(@"We don't want bad reviews");
break;
case 3:
// ask next time they launch app
NSLog(@"User should be asked next time");
break;
default:
//OK pressed return to game
NSLog(@"User pressed OK Button");
break;
}
}
- (void)checkLoad {
if (webView.loading) {
[active startAnimating];
}
}
- (void)checkNotLoad {
if (!(webView.loading)) {
[active stopAnimating];
}
}
/*- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
}
else
{
}
}*/
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (YES);
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
- (NSString *)adWhirlApplicationKey {
return @"98c53f515bdb40079484a05a0ee8f13f";
}
- (UIViewController *)viewControllerForPresentingModalView{
return self;
}
@end