AdColony + SVProgressHUD Conflict - ios

I'm experiencing some odd behavior when integrating AdColony's 2.2.4 library with an application using SVProgressHUD. If the standard configuration call is made in the app delegate...
[AdColony configureWithAppID:kAdColonyAppID zoneIDs:#[kAdColonyZoneID] delegate:nil logging:true];
SVProgressHUD no longer pops up in the app by calling
[SVProgressHUD showWithStatus#"Status..."];
Simply commenting out the AdColony configureWithAppID call causes SVProgressHUD to function again normally. Has anyone else encountered this, or found a way to make them both work in the same application?

It looks like the SVProgressHUD code is doing a check on line 436 that doesn't take into account that there can be multiple UIWindows in existence belonging to the UIWindowLevelNormal level. The consequence of this is that the HUD view is being added to the wrong window. In order to get the SVProgressHUD working, you can modify the for loop starting on line 436 as follows:
for (UIWindow *window in frontToBackWindows) {
if (window.keyWindow) {
[window addSubview:self.hudView];
break;
}
}
Please feel free to contact us (support#adcolony.com) with any further integration questions you may have.

It works for me ,I have added adcolony framework so success messages for SVProgress hud was not showing:
I comment the code:
// for (UIWindow *window in frontToBackWindows)
// if (window.windowLevel == UIWindowLevelNormal) {
// [window addSubview:self.overlayView];
// break;
// }
and replace with
for (UIWindow *window in frontToBackWindows) {
if (window.keyWindow) {
[window addSubview:self.hudView];
break;
}
}
So It works,.. .Thanks

The simplest way which worked for me is
[[[UIApplication sharedApplication] keyWindow] addSubview:self. overlayView];
This performs the same action the accepted answer.

Related

How can I present an viewController from Application window's rootViewController when user press home button, but before application enter background? [duplicate]

This question already has answers here:
Controlling the screenshot in the iOS 7 multitasking switcher
(8 answers)
Closed 9 years ago.
I have an application that contains some sensitive information, I don't want others to snapshot the screen before app enter background, so I want to present a pattern lock viewController on the screen after user press home button. I tried this code
- (void)applicationWillResignActive:(UIApplication *)application
{
PatternLockViewController *pvc = [[SMICConfig sharedSMICConfig] patternLockVC];
if (!(pvc.isViewLoaded && pvc.view.window) && [SMICConfig sharedSMICConfig].isCookie) {
[self.window.rootViewController presentViewController:pvc animated:NO completion:nil];
}
}
But the PatternLockViewController only present after the app enter foreground. So, when the app stay in background, you can double-click home button to peek some information.
Tecent qq's pattern lock is very well. I just want to implement this effect.
Can any one help me? Thanks
You can tell iOS7 to avoid using the recent snapshot image during the next launch cycle by calling ignoreSnapshotOnNextApplicationLaunch Apple's documentation
The following is how I implemented for my App. Hope it helps.
- (void)applicationWillResignActive:(UIApplication *)application {
[application ignoreSnapshotOnNextApplicationLaunch];
self.imageView = [[UIImageView alloc]initWithFrame:[self.window frame]];
[self.imageView setImage:[UIImage imageNamed:#"Default-568h"]];
[self.window addSubview: self.imageView];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
if (self.imageView != nil) {
[self.imageView removeFromSuperview];
self.imageView = nil;
}
}

iOS popup/splash screen with external web content

I need to display a popup or something like a splash screen every time I start my app. The content of this popup must be taken from an external web source (something like jpg, png or pdf).
The purpose of this popup is to warn users about news and special offers. The popup should disappear after a certain time (or at the pressure of a button).
From what I read on other threads, the UIPopoverController feature seems be helpful for what I need (as I read in this class reference), but I'm afraid that the main function of this popup is presenting a choice in result of the pressure of a button.
Why can you not simply add a webview to the screen when the app opens?
Like:
in appDelegate:
UIWebview *popover;
- (void)applicationDidBecomeActive:(UIApplication *)application
{
UIWindow *win = [[UIApplication sharedApplication] keyWindow];
popover = [[UIWebView alloc] initWithFrame:win.bounds];
... load content ...
[win addSubview:popover];
[self performSelector:#selector(dismissPopover) withObject:nil afterDelay:3];
}
-(void)dismissPopover
{
[popover removeFromSuperview];
}

App Icon won't show in music controls in app switcher

I'm writing an app that streams music and I'm having a ton of trouble setting the icon on the music control dock screen (when you double-click the home button and swipe to the left). All the documentation said to do something like this, but the icon never appears and I don't ever receive the event notification. All of this code is in my player view controller. _radioPlayer is an instance of an AVQueuePlayer. What am I doing wrong here?
- (void)viewWillAppear:(BOOL)animated
{
UIApplication *application = [UIApplication sharedApplication];
if([application respondsToSelector:#selector(beginReceivingRemoteControlEvents)])
[application beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)event {
switch (event.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
[_radioPlayer pause];
break;
case UIEventSubtypeRemoteControlPlay:
[_radioPlayer play];
break;
case UIEventSubtypeRemoteControlPause:
[_radioPlayer pause];
break;
default:
break;
}
}
EDIT: I read through the documentation and followed the steps but it's still not working. Here are some of the possible reasons I've come up with:
A. My music isn't playing yet when viewDidAppear is called. In the documentation it states
"Your app must be the “Now Playing” app. Restated, even if your app is the first responder >and you have turned on event delivery, your app does not receive remote control events until >it begins playing audio."
I tried calling beginReceivingRemoteControlEvents: and becomeFirstResponder: after the music starts playing but this doesn't work either. Can these only be called in viewDidAppear:? Does iOS automatically detect when the music begins playing so this isn't necessary?
B. There is something weird about using an AVQueuePlayer. I'm almost positive this isn't it since the event message is handled by the view controller, not the player itself.
It may not working for you because you are calling beginReceivingRemoteControlEvents in viewWillAppear instead of viewDidAppear. Check out the documentaion -
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// Turn on remote control event delivery
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
}

UIApplication's -canOpenURL: -openURL: return misleading result

Since iOS6, I can't tell whether the application can launch Safari or not.
If Safari is restricted on the device (Settings>General>Restrictions), nothing happens when trying to open a URL, and there's no indication of what went wrong:
NSURL *url = [NSURL URLWithString:#"http://www.google.com"];
[[UIApplication sharedApplication] canOpenURL:url]; // Returns YES
[[UIApplication sharedApplication] openURL:url]; // Returns YES
However, Safari does not launch, and the user is left wondering why my buttons are "broken".
This seems like a bug to me so I filed a radar #12449905.
Is there another way to solve this problem?
If this is an Apple bug, then it looks like the thing for you to do is to program around it. Once the user clicks the button, you can always write something like this:
[self performSelector:#selector(notifyUserOfRestrictedAccess) withObject:self afterDelay:.5];
In the app delegate, you can set a property such as:
- (void)applicationWillResignActive:(UIApplication *)application {
self.openingExternalProgram = YES;
}
In your view controller, create the method like this:
-(void) notifyUserOfRestrictedAccess {
if (!appDelegate.openingExternalProgram) {
// Message the user via UIAlertView about restricted Safari access
}
appDelegate.openingExternalProgram = NO;
}
I'm sure there are better ways, but at least you don't have to wait on Apple.

ActivityIndicatorView in nav bar continues animating after ViewDidLoad

I have an issue with the activity indicator view continuing to animate after the page has finished loading. The problem only occurs on UIWebView pages that have already been visited.
I am also using MBProgressHUD and this stops animating after the ViewDidLoad as expected.
The page loads almost instantaniously and then the animation starts in the nav bar. It's almost as if the page is pulled from the device cache and then the application looks to go and load it.
The spinner only stops animating when you visit a different view controller.
Has anyone else faced issues similar to this?
EDIT
- (void)showNetworkActivity {
[self performSelector:#selector(showNetworkActivityWithDelay) withObject:nil afterDelay:0.5];
}
- (void)showNetworkActivityWithDelay {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}
- (void)hideNetworkActivity {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
Works okay when I remove the delay.
I inherited the code, so I'm not sure whether the delay is needed. Is there any good reason to have a delay on showing the networkActivityIndicator?
Here the solution.
Try to call [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; directly.
performSelector:withObject:afterDelay: schedules a timer on the same
thread to call the selector after the passed delay.
I don't see reasons to use the delay in this examples. In fact, if you use it, the selector showNetworkActivityWithDelay is called after a delay and you could not see it immediately on the screen.
Obviously you can continue to wrap the activity indicator logic with the previous methods like the following (but it's not necessary):
- (void)showNetworkActivity {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}
- (void)hideNetworkActivity {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
Sounds like you don't have UIWebViewDelegate set up. Set the delegate in the header/implementation, then start animating the indicator in UIWebViewDelegate webViewDidStartLoad, then stop animating in webViewDidFinishLoad and webViewDidFailLoadWithError.

Resources