iAd Doesn't Animate Ad Appearance - iphone

I'm implementing iAd in my app using the paradigms for a multi-VC app that apple demonstrates in their sample code (e.g. TabbedBanner and NavigationBanner). If you're not familiar with it, the paradigm is essentially to have the main app delegate serve as the primary AdBannerViewDelegate, and share the banner view across your respective view controllers.
My ads are appearing fine throughout the app, without any warnings. The problem is that for some reason when I click an ad banner, it doesn't navigate the appearance of the ad (should slide up from the bottom). There's just a delay and then the ad appears. But when I dismiss the ad it animates fine.
The appearance animates fine in apple's sample code, so the problem lies somewhere in my code. I'm just not sure where because I haven't changed much in the iAd implementation. My bannerViewActionShouldBegin is just
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
[[NSNotificationCenter defaultCenter] postNotificationName:BannerViewActionWillBegin object:self];
return YES;
}
But I don't think the problem lies in the NotificationCenter, because if I comment out that bit and just do
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
return YES;
}
The problem remains.
Any ideas? I can post more code, but my digging around in the documentation hasn't revealed anything that would flip an animated BOOL for ad presentation.
Thanks in advance.

FWIW, the best I could figure is that this seems to simply be an iOS version issue. In 4.0 it fails to animate. In 5.0 it animates.

Related

cut/copy/paste functionality stopped working in my iOS application

UPDATE: cut/copy/paste disabled in my app.
I am confused with my iOS app while developing for iPhone devices. Execution flow enters a point like the code below
[self navigationController] pushViewController:chooseDeviceView animated:YES];
[chooseDeviceView release];
[numberTextField setText:#""];
The view changes and things "work properly". The problem is that after this the cut/copy/paste functionality is missing in my app.
Don't really know how to start debugging the issue. Does it ring a bell to anybody?
That was a very complicated issue for a beginner. Finally the issue was a little bit related with status message corrupts main window in my iPhone app
Add in your new viewController this:
- (BOOL)canBecomeFirstResponder {
return YES;
}
It should solve your issue.

iPod Touch iOS 5.1.1 Not calling viewDidDisappear:animated

I've posted this question elsewhere, but as SO is such a great community I'm doing so here as well.
First up, I'm using Cocos2D 2.0-gles20 to put a multiplayer/team oriented game together.
I've been integrating GameKitHelper into the app. To date it's been working just fine on my iPhone4 and iPad2 and in the Simulator, but now when I try to use it on an iPod Touch 4th I'm getting assertions in [CCDirectorIOS startAnimation] because the app is getting a viewWillAppear when it shouldn't and no call to viewDidDisappear when it should.
The reason this matters is that these methods on the CCDirectorIOS class cause Cocos2D to start/stop animation whilst another UIKit view is in front. This is something that I've managed myself with Cocos2D-0.99 but with 2.0 it is handled nicely within the director so that each app doesn't have to handle it specifically.
The GameKitHelper class has the following methods for pushing a GKMatchmakerViewController onto the screen:
-(void) showMatchmakerWithInvite:(GKInvite*)invite
{
GKMatchmakerViewController* inviteVC = [[[GKMatchmakerViewController alloc] initWithInvite:invite] autorelease];
if (inviteVC != nil)
{
inviteVC.matchmakerDelegate = self;
[self presentViewController:inviteVC];
}
}
-(UIViewController*) getRootViewController
{
return [CCDirector sharedDirector];
}
-(void) presentViewController:(UIViewController*)vc
{
UIViewController* rootVC = [self getRootViewController];
[rootVC presentModalViewController:vc animated:YES];
}
-(void) dismissModalViewController
{
UIViewController* rootVC = [self getRootViewController];
[rootVC dismissModalViewControllerAnimated:YES];
}
When I call showMatchmakerWithInvite, on the iPhone4, etc I see a call to viewDidDisappear: on the CCDirectorIOS object which stops animation. This is fine. When the GK view is gone, I see a call to viewWillAppear which restarts the animation. Sweet.
On the iPod Touch however, running exactly the same project, the call to viewDidDisappear is not made, but a call to viewWillAppear is, before the GK view has gone.
I can't fathom why there would be a difference. All devices are running iOS 5.1.1.
It's almost as if the behaviour of UIKit is different on the iPod Touch, but I find that hard to believe. My other thought was that I was looking at a timing issue, but I put some code in to allow the app to keep running even with the problem, but the call to viewDidDisappear never happened.
I can work around this I think by managing the start/stop of animation myself, but I would have preferred not to customise the Cocos2D code.
Does anyone have any ideas?
Thanks
Well, being the impatient person I am, rather than leave it to others and work on something else, I nutted it out.
I turns out that the iPod Touch devices in question had multi player games disabled in the restrictions app. This seems to cause the GK view to not show "properly" and as a result the events like viewDidDisappear: and viewWillAppear: don't occur the way I was expecting.
So I've been able to revert all of my tweaks and instrumentation in the Cocos2D code, and simply apply a correction to the GameKitHelper class to ensure that if features such as multi-player are disabled, the player isn't able to request them.

2 XIB and 1 viewcontroller but functions don't work in the ipad XIB

I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will.
I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects ( enlarged ;-) ) . I added the callbacks to function correctly with IB.
I can see everything fine and arrive on my new ipad view BUT when I click on one of my buttons... nothing happened like if my callbacks don't work. It is very surprising and actually I have no idea where to look as I compared most of the parameters between my iphone and ipad view and they are identical as far as I can see.
It must be something damn obvious so if one of you had the same issue and it was a very simple answer ... I guess that would be what I missed!
Thanks for your help in advance
Cheers,
geebee
EDIT1: Some code as requested
at start I have that to decide either way:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
examTFVC_NIB=#"ExamTFViewController-iPad";
}
else
{
examTFVC_NIB=#"ExamTFViewController";
}
Then to go to the right view:
ExamTFViewController *examTFViewController = [[ExamTFViewController alloc]
initWithNibName:globals.examTFVC_NIB bundle:nil];
But I have no problem loading the correct XIB. The issue is really the callback functions not being called...
Thanks for the help.
EDIT2:
I also realised that calling the extension of the xib xxx~ipad allows to avoid the example code above. And it works - but still no function can be called.
EDIT3:
IMPORTANT FINDING: if I move my buttons higher and on the left of the screen: they work! So it seems that the functions are called if the event are in the region of an iphone screen although I am on an ipad screen. I guess know it would be more obvious to find the issue! thanks for any help – geebee just now
ANSWER
iPad touch detected only in 320x480 region
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// to correct region size
CGRect rect = [[UIScreen mainScreen] bounds];
[window setFrame:rect];
// now, display your app
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
** OR OTHER SOLUTION **
Check the full screen at launch checkbox - only present in the ipad xib MainWindow
finally solved - with 2 methods - programmatically or via IB - in the edited section of the post.

iAd giving problems with Shaking Motion

I have an application that needs to detect a shaking motion to start/restart its activity. It is already on-Line, but now I want to add the new feature of iAd. I've implemented all the needed methods, but I have a problem: when I enter the Ad and then exit, the device can't catch the shaking motion anymore.
Ideas? Hint.
Thank you.
In the below stackoverflow link:- How to use Shake API in iPhone SDK 3.0?
detailed info is provided. check this.
hope it helps
Solved, actually I get the problem reading diggin into answers linked by Srinivas.
The problem was that when the Ad is end and returns back the control to my UIViewController, this one is no more the First Responder setted on his view. The solution:
- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
[[self view] becomeFirstResponder];
}
Nothing more.

Hiding iAds programmatically in iPhone

Currently I am showing iAds in my app.They are working fine.Now, I want to hide the iAds based on some conditions in code.
What I am using is
ADBannerView *bannr= (ADBannerView *)[self.view viewWithTag:1];
bannr.hidden = YES;
bannr.userInteractionEnabled = NO;
iAds get hidden.But when i press the area where iAd is supposed to be.Advertisement details window popup
With my iAds I transition them on or off screen after the relevant callbacks are received by it's delegate.
It works for me fine.
Hope this helps
Good Luck,
Since ADBannerView is a subclass of UIView you should be able to remove it using removeFromSuperview.
[bannr removeFromSuperview];
It doesn't explain why you still can interact with the hidden view but you should be able to keep going.
Update
Alternative solution: If the ad gets triggered even when hidden you can perhaps try this in the delegate:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
if (banner.isHidden) {
return NO;
}
// Business as usual
}