iPhone - temporarily disable keyboard - iphone

G'day All
My app has a first run component that presents a login/signup screen & on successful login/signup moves on to loading the app's data. For those who've seen it the process follows similar style to that in Instagram. If the keyboard is dismissed on entering the password & there's an error it pops back up as soon as it's gone which strikes me as not being a great look. So is there any way to disable the keyboard or prevent user interaction without actually dismissing it while the app sends the user credentials & waits for a response?
Cheers & TIA, Pedro :)

After the first dismiss, I would set the UITextField as disabled. No user Interaction is possible anymore and the keyboard shouldn't pop up anymore. This will also have the nice UI touch of being greyed out.
Additionally, you should have a TextFieldDelegate 1 implement textFieldShouldBeginEditing: and return NO;. That will cause the keyboard to not appear.

Related

How to know when user has closed modally presented controller by tapping on title?

Is there a way to know in code when user has closed a modal by tapping the title? Apple's documentation states:
The title of the modal interface is set to the string Cancel unless the presented interface controller explicitly changes it using the setTitle: method. Tapping the title dismisses the interface automatically.
As far as I know there is now way to replace that title with a button.
I could fire a notification on didDeactivate() or willDisappear() but these will also be called when app enters background. So I could do an additional check in ExtensionDelegate's applicationWillResignActive() to differentiate between user's action in my app or outside my app but this seems very fragile.
Are there any better ways?
Why would one need this?
In my case I have an initial screen where a user makes a choice. After the choice is made I present screens that contain data based on that choice.
I always want to show the data when the choice has been made. So I save the choice and present the modal on app launch when it is present.
But I don't want to show the data if the user has closed the data display. Yet I still want to display the choice made on the first screen. So I can't use the fact that the choice has been made to trigger modal displaying.
Hence I need to know if the modal has dissapeared because of user interaction in app or because the app got switched away.
Unfortunately, there is no other way to do so.
But why do you need to add additional checks at applicationWillResignActive()? I think there is no need to do so.

UINavigationButton & UIButton on PopToRootViewController?

My app has a sign in button and a sign up button, which are UINavigationButtons and UIButtons respectively. Either segues to a new screen that, on success, should PopToRootViewController; However, when I successfully sign in, my sign in and sign up buttons are still present. I have a method that decides whether or not to display the buttons that gets called in the viewDidLoad method. Thus, when I stop/run the app again, the buttons disappear as they should. Can anyone give me advise on how to get these buttons to hide? Thank you.
Bonus points: I also have a log out button that has a similar issue; I have to re-run the app before my view controller realizes it should hide the logout button and show the sign in/up buttons.
The problem is that viewDidLoad is only called once, so it is hardly suitable for this purpose; it has to do with the view coming into existence, and nothing to do with the interface. Use viewWillAppear: and make the decision about whether to show or hide the buttons on the basis of, say some info you've stored in NSUserDefaults (like, has the user signed in or not).

How do I stop the keyboard from blocking an external notification's close buttons on iOS?

I have a UIAlertView with a text field in it. This view works correctly; it appears in the top half of the screen, so when the keyboard comes up, both buttons and the text entry are still visible and tappable.
However, if a local or remote notification from another application comes in while the text field is the first responder and the keyboard is up, it hides my alert and places the new alert behind the keyboard. If the alert is more than one line long, its buttons cannot be clicked and the user cannot dismiss it. It's not dismissing my alert view via any of the normal mechanisms - neither alertView:clickedButtonAtIndex: or alertView:cancel: get called on my delegate - but rather simply hides it temporarily using some unknown mechanism.
Can I get notified when a notification hides my alert view, so I can dismiss the keyboard and let the user deal with the notification? Are there any other events I can hook into to catch this case?
Register for the application’s UIApplicationWillResignActiveNotification; when you get that, dismiss your alert view. From the docs:
An active application can be said to have focus. It gains focus after being launched, loses focus when an overlay window pops up or when the device is locked, and gains focus when the device is unlocked.
Alert views, such as those presented by notifications from other apps, are overlay windows. Watch for that notification, close your alert so the keyboard doesn’t get in the way, and be prepared to re-display the alert if your app then gets the UIApplicationDidBecomeActiveNotification.
I hope this will help...
- (void)willPresentAlertView:(UIAlertView *)alertView {
if (newAlertViewWhichBlocks.tag == alertView.tag) {
[yourTextField resignFirstResponder];
}
}
Do remember to set delegate of alert view.

xcode iphone app problem with app not closing on ad click

I have a webview inside mainwindow.xib. Te webview shows an admob ad and when clicked it is supposed to close the app and open the app store. For some reason this is not happening. When the ad is clicked nothing happens. Can this be due to the webview being inside main instead of a viewcontroller? If not then what can be causing this?
It's possible that some other view is intercepting the touches, the UIWebView has user interaction disabled, or the view the UIWebView is a child of has user interaction disabled.
It's hard to say exactly without some more information. Can you take a screenshot of how the mainwindow.xib is laid out?

Detecting when 'Home' is pressed or app is resumed (Keyboard is covering View when it resumes)

In my iPhone app, if the user presses the Home button while the keyboard is up, then returns to the app, the keyboard is still up but my view behind is hidden behind it!
I have some code that normally would rise and lower the view as necessary, but I can't see how to call it in this situation. How can I either detect when Home has been pressed so I can lower the keyboard, or detect when the app has been resumed so that I can rise my view?
Your application delegate is sent the applicationDidEnterBackground: message:
You should perform any tasks relating to adjusting your user interface before this method exits
you can check with some notification and try this