I have a RevMob banner in Swift, its working perfectly but when opening an UIActionSheet the cancel button gets covered by the advertisement, this also happens with GameCenter , what should I do to fix it?
My code:
func appearAd(){
if revMobSession == true{
RevMobAds.session().showBanner()
}
}
Related
I use this code in AppDelegate:
- (BOOL)accessibilityPerformMagicTap {
NSLog(#"Appdelegate = %s",__func__);
return YES;
}
When I click the home button and two-fingered double tap while using VoiceOver activates, this method is not invoked. What is the reason for this? How can I use this method with my music app?
You cannot. The method is called on the focused accessibility element while the app is foregrounded.
I am currently making an iOS game using sprite kit. In one of my SKScenes, my store scene, the user can watch an AdColony ad. The ad plays fine, but after it is finished, the store scene is deallocated and the app returns to the menu screen. Why is this happening, and how can I return to the store scene without deallocating it?
Edit: Here's my code
//User taps a button (really a skspritenode)
//UIAlertView pops up asking them to watch a video
alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
//User tapped button 1 (aka agreed to watch video)
if (buttonIndex == 1){
//Present video
[AdColony playVideoAdForZone:#"xxxxxxxxxxxxxxxxxxxx" withDelegate:self];
}];
}
I have an animating sine wave in my app that needs to be reset when the user hits the home button or locks their phone (turning off the screen). Once the user brings the app back to the foreground, the sine wave animation is triggered again. This works fine until I realized it was occurring when the microphone access permission pops up. So the microphone access pops up, causing my app to go into the background and the animation to turn off, but the app is still visible. Any way I can know that the mic access pop up is occurring, so I can make some kind of if statement?
-(void) appDidEnterForeground:(NSNotification *)notification
{
if( viewIsUp == NO)
{
[self.sineWave.layer removeAllAnimations];
}
else
{
[self.sineWave animateWave];
}
}
-(void) appDidEnterBackground:(NSNotification *)notification
{
if(viewIsUp)
{
[self.sineWave.layer removeAllAnimations];
}
}
I accidentally set UIApplicationWillResignActiveNotification as the notification to call appDidEnterBackground. When the microphone access pop up would display, the only notification that would get called was UIApplicationWillResignActiveNotification. So when the home button was tapped or the screen was locked, I would remove the animation when UIApplicationDidEnterBackgroundNotification was called and when the mic access pop up displayed, I would leave the animation as it is when UIApplicationWillResignActiveNotification gets called. Worked out nicely. Hope this helps someone.
iOS 7 bring the iAdAdditions category to UIViewController.
With it managing a banner is a matter of one line of code:
self.canDisplayBannerAds = YES;
But I wonder how to detect user touching the iAd banner. My need is to pause game behaviors (music, animations, timers...) while iAd is displayed full screen.
I have tried the following code:
- (void) viewWillDisappear:(BOOL)animated {
if ([self isPresentingFullScreenAd]) {
// view will disappear because of user action on iAd banner
}
else {
// view will disappear for any other reasons
}
}
- (void) viewWillAppear:(BOOL)animated {
if ([self isPresentingFullScreenAd]) {
// view will appear because full screen iAd — caused by previous user action on iAd banner — is dismissed
}
else {
// view will appear for other reasons
}
}
I have done some testings showing everything is OK. But I wonder if it's the correct way to implement it!
UPDATE
This is the solution I use in the production version of the application and everything is fine: no problems has showned.
You can use these specific delegates in your view controller, here's code ripped straight from my game where I toggle the audio/music off when a banner is clicked.
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner
willLeaveApplication:(BOOL)willLeave
{
[[CPAudioManager sharedInstance] toggleOnOffDependingOnSettings];
return YES;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
[[CPAudioManager sharedInstance] toggleOnOffDependingOnSettings];
}
For full screen interstitials the code is roughly the same, but you don't get such nice delegates.
You know when you are showing a full screen ad when you call requestInterstitialAdPresentation and it returns YES, e.g.
if( [self requestInterstitialAdPresentation]==YES ) {...}
You should pause your views, toggle your music off, and kill your banner view (probably).
Then, you know when the user has closed the interstitial in ViewDidAppear
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if( self.isPresentingFullScreenAd )
{
// we are about to stop presenting full screen ads
// unpause view
// enable banner ads
// turn music back on if it was playing before
}
else
{
// we are presenting the normal view or the full screen ad
}
}
I am working on an iPad application which uses Motorola CS3070 bar code scanner. I am connecting the scanner as using HID Profile and it is treated as a bluetooth keyboard by iPad. When scanner is connected to iPad using bluetooth and if we focus on any textfield inside application, it won't open device virtual keyboard. This is expected as device treats bar code scanner as bluetooth keyboard.
While doing scanning if the scanner is disconnected, device virtual keyboard will be displayed. When this happens we want to show an alert instead of having keyboard displayed on the screen. We are using keyboardWillShow notification to differentiate whether device virtual keyboard is displayed or not. Inside keyboardWillShow we tried hiding the keyboard. This works when we disconnect the scanner and then select a text field. But this is not working when the focus was already in a textfield and device connects to bluetooth keyboard and if we disconnect the bluetooth. We see keyboard device virtual keyboard getting displayed in that case. I checked the code inside the keyboardWillShow and it is getting executed both the times. Also when it is not working, the keyboard which gets displayed on screen is not responding when we click on any keys.
Please let me know if we can hide keyboard when it switches between bluetooth keyboard to device virtual keyboard.
Please see below code in keyboardWillShow,
-(void) keyboardWillShow: (NSNotification *) theNotification
{
Global *obj=[Global getInstance];
if (obj.selectedStartScan == true) {
UITextField *theTextField = [theNotification object];
//[theTextField resignFirstResponder];
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:#"Error"
message:#"Scanner is not Connected"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[self.window.rootViewController.view endEditing:YES];
NSLog(#"inside if obj.selectedStartScan :.........");
[errorAlert show];
}
}
Thanks in advance.
When you get notification , just call the
[UItextFiled ressignFirstResponder]
This will hide the keaboard