iAd will not display after uploading app to store - objective-c

When I test my app on my device, from Xcode, the iAd works, but when I have uploaded it to the App Store and test it on a friend's iPhone, it's just white!
Here is my code:
.h:
#interface pinpongViewController : UIViewController {
ADBannerView *banner;
}
#property (nonatomic, assign)BOOL bannerIsVisible;
#property (nonatomic, retain)IBOutlet ADBannerView *banner;
#end
.m:
#synthesize banner, bannerIsVisible;
-(void)bannerViewDidLoadAd:(ADBannerView *)abanner {
if (!self.bannerIsVisible) {
[UIView beginAnimations:#"animatedAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0.0, 50.0);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
-(void)bannerView:(ADBannerView *)aBanner didFailToReceiveAdWithError:(NSError *)error {
if (!self.bannerIsVisible) {
[UIView beginAnimations:#"animatedAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0.0, -320.0);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
#end

Have you enabled the iAd network for your app, before submitting to the app store? It is required to enable iAd network(in iTunes connect) or else only a white screen appears! Hope this helps.

Related

Why doesn't my animation loop?

I need to perform a blinking effect on a image once the user click on a particular button. But my code doesn't work:
- (void)next
{
[UIView animateWithDuration:2.0f delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{
NSLog(#"Done"); // <- USED AS COUNTER
[image setAlpha:0];
[image setAlpha:0.5];
} completion:nil];
}
What happens is my image changing its alpha to 0.5 and stops. Furthermore my console shows DONE just one time. What did I wrong?
I just created a test project and this blinked just fine...
#import "ViewController.h"
#interface ViewController ()
#property (nonatomic, strong)UIView *blinker;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.blinker = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
self.blinker.backgroundColor = [UIColor greenColor];
[self.view addSubview:self.blinker];
[self next];
}
- (void)next
{
[UIView animateWithDuration:2.0f delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{
NSLog(#"Done"); // <- USED AS COUNTER
[self.blinker setAlpha:0];
[self.blinker setAlpha:0.5];
} completion:nil];
}
With the exception that you expect the log to continue to print out in the console. So I suspect you are doing something to your image. You aren't calling self. so I am guessing it is an instance variable (ivar) and you are changing what it points to somewhere else in the code.
If you need a counter to go off every blink you may want to consider something like this...
#import "ViewController.h"
#interface ViewController ()
#property (nonatomic, strong)UIView *blinker;
#property (nonatomic,)NSInteger counter;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.blinker = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
self.blinker.backgroundColor = [UIColor greenColor];
[self.view addSubview:self.blinker];
[self next];
}
- (void)next
{
[UIView animateWithDuration:1.0 animations:^{
self.counter++;
NSLog(#"Counter: %#", #(self.counter));
self.blinker.alpha = 0.0;
} completion:^(BOOL finished) {
[UIView animateWithDuration:1.0 animations:^{
self.blinker.alpha = 1.0;
} completion:^(BOOL finished) {
//check to see if you want to continue blinking if so call next again
[self next];
}];
}];
}
I don't have any context as to why you want to count, but hopefully that helps.

How can I get iAd to fly in to prevent white box?

I am using a shared method to have iAD appear across three view controllers and using the App Delegate. The issue I am having is that when ads do not appear it is forming the white box. I know Apple will not approve the app if the white box appears. What can I code to have the ad start off screen and have it fly in when an ad is present and when an ad is not present, have it fly off.
I assume I would change this on all three views.
Here is the code for each .m
- (AppDelegate *) appdelegate {
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
-(void) viewWillAppear:(BOOL)animated{
_UIiAD = [[self appdelegate] UIiAD];
_UIiAD.delegate = self;
[_UIiAD setFrame:CGRectMake(100,700,320,50)];
[self.view addSubview:_UIiAD];
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(#"ads loaded");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[_UIiAD setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(#"ads not loaded");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[_UIiAD setAlpha:0];
[UIView commitAnimations];
}
If it helps, ads are being place on the bottom of a landscape mode iPad
Try this code:
Write this in your .m file:
-(void)AD_init
{
_adBanner = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height, 320, 50)];
_adBanner.delegate = self;
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!_bannerIsVisible)
{
if (_adBanner.superview == nil)
{
[self.view addSubview:_adBanner];
}
[UIView beginAnimations:#"animateAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations];
_bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(#"Failed to retrieve ad data");
if (_bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
_bannerIsVisible = NO;
}
}
And in your .h file :
BOOL _bannerIsVisible;
ADBannerView *_adBanner;
Answer supplies above. It now works for shared screen iad.

iOS8 animation code does not work anymore

The code I used to animate a UITextField worked for me until XCode Version 6.0 (6A215l). Now XCode6 Beta7 not reposition UITextField. What should I do to make it work?
Here the code:
#interface TableConfigViewController ()
#property(nonatomic, strong) IBOutlet UITextField *customTableName;
#end
- (void)viewDidLoad
{
[super viewDidLoad];
[self.customTableName setDelegate:self];
}
- (void)animateTextField:(UITextField*)textField
up:(BOOL)up
{
const float movementDuration = 0.5f;
const int movementDistance = 380;
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: #"animation" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:movementDuration];
self.customTableName.frame = CGRectOffset(self.customTableName.frame, 0, movement);
[UIView commitAnimations];
}
- (void)textFieldDidBeginEditing:(UITextField*)textField
{
[self animateTextField:textField up:YES];
}
- (void)textFieldDidEndEditing:(UITextField*)textField
{
[self animateTextField:textField up:NO];
}
Thank you very much in advance
Not sure if this is the source of your problem but you should consider using the block based APIs (available since iOS 4.0) for UIView animations.
From Apple's docs regarding beginAnimations:context:
"Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead."
For example (untested):
- (void)animateTextField:(UITextField*)textField
up:(BOOL)up
{
const float movementDuration = 0.5f;
const int movementDistance = 380;
int movement = (up ? -movementDistance : movementDistance);
[UIView animateWithDuration:movementDuration
animations:
^{
self.customTableName.frame = CGRectOffset(self.customTableName.frame, 0, movement);
}
];
}

UIView Animation in SKScene

UIView Animation isn't working in SKScene
MyScene.h
#property (nonatomic) SKLabelNode *tutorialLabel;
MyScene.m
- (IBAction)hideLabel:(id)sender {
[UIView animateWithDuration:1 animations:^(void) {
[_tutorialLabel setAlpha:0.0];
}];
}
Is there a better way to hide an SKLabelNode
If you want to fade out the label, you can use SKActions:
- (IBAction)hideLabel:(id)sender {
[_tutorialLabel runAction:[SKAction fadeOutWithDuration:1.0f]];
}

Animate image out of view

I want a button to trigger the following action. When clicked it's supposed to push my logo up and out of the view and remove it. When it's clicked once more it's supposed to do the reverse thing. Meaning the image is created and pushed down back into the view. I'm using storyboard to set up my interface. My issue is that I can't get the animation to trigger. Posting my code below:
In TableViewController.h
#interface TableViewController : UITableViewController{
BOOL status;
}
#property (weak, nonatomic) IBOutlet UIImageView *animateLogo;
#property (weak, nonatomic) IBOutlet UIButton *button;
- (IBAction)onClick:(id)sender;
- (void)showHideView;
#end
In TableViewController.m
#synthesize animateLogo, button;
- (void)viewDidLoad{
[super viewDidLoad];
status = YES;
}
- (IBAction)onClick:(id)sender{
[self showHideView];
}
if(status){
[UIView
animateWithDuration:1.5
delay:0
options:UIViewAnimationCurveEaseOut
animations:^{
[animateLogo setFrame:CGRectOffset([animateLogo frame], 0, -animateLogo.frame.size.height)];
}
completion:^(BOOL completed) {}
];
status = NO;
[button setTitle:#"Show" forState:UIControlStateNormal];
}
else{
[UIView
animateWithDuration:1.5
delay:0
options:UIViewAnimationCurveEaseOut
animations:^{
[animateLogo setFrame:CGRectOffset([animateLogo frame], 0, animateLogo.frame.size.height)];
}
completion:^(BOOL completed) {}
];
status = YES;
[button setTitle:#"Hide" forState:UIControlStateNormal];
}
}
EDIT:
The animation is working if I programmatically code the UIImageView. So the issue is with the storyboard somehow. I prefer to get this working with storyboard so I can get a better overlook on the layout.
UIImage *test = [UIImage imageNamed:#"logo.png"];
animateLogo = [[UIImageView alloc] initWithImage:test];
[self.view addSubview:animateLogo];
[animateLogo setFrame:CGRectOffset([animateLogo frame], 0, animateLogo.frame.size.height)];
Problem sovled. I used a different approach were I animated the UIView instead of the UIImageView. I's now working like a charm.