MBProgressHUD blocking user interaction - objective-c

My application has a MBProgressHUD on the screen while the CLLocationManager is getting the user current location at a separate thread in the background. Sometimes the location process start to take so long and obviously I would like to let the user decide to leave or not the screen. The problem is that the User Interface seems to be blocked by the MBProgressHUD so the user can't press the back button.
Is there any implementation design to solve this problem?

In order to achieve a non-modal behavior, simply disable the user interaction on the MBProgressHUD so that the touches will fall through it.
Objective-C
theHUD.userInteractionEnabled = NO;
Swift 4.x
theHUD.isUserInteractionEnabled = false

Related

View size when subclassing PFLogInViewController

When subclassing PFLogInViewController for customization. How do I change the size of the view?
I have looked at this tutorial: https://parse.com/tutorials/login-and-signup-views
but it does not seem to have the answer.
My app is based on a UITabBarController and one of the tabs needs log in.
Nevertheless if the user cannot log in, he should still be able to use the other tabs.
In the present situation, when the user taps on the tab asking for login; he has to log in or kill the app to get out. Because the PFLogInViewController takes up all the screen and there is no way out by hitting a different tab (all covered).
This is obviously not very nice.
How can I keep the tabs at the bottom visible?
I tried to change the self.view.frame or the self.logInView.frame in the viewDidLoad method of my PFLogInViewController subclass, but it seems to have no effect at all.
Then you should make your app so that it doesn't start with the login viewcontroller, but rather opens to the parts that are available to all. Include some button or other mechanic to take the user to the login page.
You could include a button on the login page that says "Use the app anonymously" or similar, which triggers a segue to a main view. On subsequent app launches, the user is taken to this main view immediately. You would still need a way for the user to login later on.

Covering the root view with another immediately upon launch or resume

I'm trying to build a security app that prompts the user to enter a passcode before allowing access to the application. This is done on the first launch or when the application is resumed.
Right now, I'm using a view controller, PasscodeViewController, which is presented modally on application launch or resume, i.e., in the app delegate:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!self.passcodeViewController.view.window)
[self.window.rootViewController presentViewController:self.passcodeViewController animated:NO completion:NULL];
}
The problem is that the main view controller's view is flashed momentarily before the PasscodeViewController is presented. This is a security risk because the user can quickly get a glimpse of the data before being asked to enter a passcode.
How do you solve this? How do programs like DotLockData, and other security programs, implement such a feature?
Seems it would be better to do that sort of thing on suspend rather than resume. Perhaps in applicationWillResignActive

UIAlert during splashcreen

This is a two part question.
I have created a user agreement that the user must agree to when first launching the app (it is an alert with some information and agree/ do not agree button)
I call upon the method that creates this alert inside myAppDelegate.m and within the method
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
The problem is the alert pops up when the splash screen has finished loading and my first view comes up. I want this to happen during the splash screen. How would I do this?
The second question is When the users presses the "Do not agree button", I want them to exit the app so I have programmed it with
exit(0);
Is there a better way and will apple reject my app because of this?
Thanks in advance
1) You can't -- during the splash screen (your default.png) the app is loading into memory, and it cannot therefore execute any code, including presentation of a UIAlertView. That's why you don't see the alert until the splash disappears -- removal of the splash screen is the last thing that the app does before calling applicationDidFinishLoading:withOptions:.
What you can do is create a view controller that mimics your splash screen. This is easy -- you can even reuse default.png as a background if you want, though a better idea is just to present in this first view controller your agreement text and agree/disagree buttons.
As to your question re: use of exit(), it's best to avoid doing that. If the user refuses, you can simply do nothing. Of course, if you go the view controller route as I suggest, you can leave presented another opportunity for the user to agree.
Another thought is that Apple allows you to customize the EULA of your app when you upload a binary -- you could put it there and be covered.
Why not load our default.png as the background of you initial view and just handle the Alert in it's controller. you can always add another view or segue based on the answer.
The problem is the UIAlert blocks the Main thread, so it could stop your app from launching in time, and the process could be terminated.

Fullscreen ad causing keyboard to not appear

My iOS app sometimes displays a Greystripe fullscreen ad on startup. If this ad shows, then when I dismiss it, later I will tap a textfield in a UIWebView but the keyboard won't show up. However, if the Greystripe ad DOESN'T appear, then all is well and the keyboard will show up as expected.
After doing some research I think it has something to do with Greystripe making itself the first responder, but I'm not sure how to fix this.
Edit:
I use adwhirl and so to get the startup ad I do exactly as it says here: http://wiki.greystripe.com/index.php/AdWhirl
The UIWebView is inside another controller that is presented with presentModalViewController:animated: from the main view.
I narrowed the problem down: the problem is caused after initiating Greystripe, which occurs either from the full screen startup ad that I initiate manually or from AdWhirl automatically initiating it to display a 320x50 Greystripe banner.
After hours of debugging I finally figured it out. I use SVProgressHUD to show loading status while my UIWebView is loading. SVProgressHUD.m makes itself the key window, then when it is dismissed, it returns the key window status to the "topmost" window. For some reason Greystripe, unlike all the other ad networks I'm using, makes itself the topmost window. So the problem could be Greystripe making itself too important, or SVProgressHUD miscalculating the topmost window!
To solve this, I had to manually make my view controller which contains my UIWebView the key window every time after dismissing SVProgressHUD:
[SVProgressHUD dismiss];
[self.view.window makeKeyWindow];

Need to hide transition when app enters from background to foreground in iphone

I am having two controllers like
firstController and secondController
When am in firstController am clicking on home button its going to background state,
but, when am again enters to foreground i need to show secondController instead of firstController.
For that I am implementing code in forground to navigate to secondController its navigating but first its showing firstController and then its showing secondController I need to avoid that how to do am not getting.
Please anyone help me to solve this.
Thanks in Advance.
Regards,
Sai.
When your app goes to the background, iOS takes a screen shot of it's state. Therefore when you push your controller at the didEnterBackground stage, it won't make a difference at next activation whether you pushed another controller or not - the screenshot of second controller will be shown regardless.
Now, the good practice is to hide sensitive information when the app resigns active in the willResignActive app delegate. You could also try pushing your secondController when the app resigns active but then you will need to keep track of whether it ever went to the background or not and push the firstController when app becomes active again (in case it never went to the background)
Hope this explanation makes sense