In my app, I have a pretty standard phone number verification screen. So the user enters their phone number then gets to a "verification" screen like so:
The system sends them an SMS message, and they get a notification:
If the user swipes down on this notification, they get the following screen:
Now when they're done and tap on the "X" icon, they get back to the verification screen, however the keyboard has disappeared:
Under normal circumstances, you could tap on the text field and the keyboard would come back, however I'd like to save the user that step and have the keyboard reappear automatically (and besides, the text fields in this case aren't tappable anyway).
I could try using the UIApplicationDidBecomeActive notification, but I thought there might be something else more elegant.
Add textfield firstResponder in viewWillAppear().
override func viewWillAppear(){
super.viewWillAppear(true)
self.tfVerification.becomeFirstResponder()
}
Related
I have an iOS 9+ app with a textView that, when clicked in, opens the keyboard and slides up with it. It slides back down when the keyboard is dismissed. So far, so good.
When the app is sent to the background while the keyboard is open with the textView on top of it, then when the app resumes the textView is sent back to the bottom behind the keyboard (after a split second), but the keyboard remains open. The scenario is explained in this other SO question.
Thanks to that question I have a watcher and can run this:
#objc func willEnterForeground(_ notification: NSNotification!) {
view.endEditing(true)
}
...and that works to hide the keyboard "almost" seamlessly.
But I really want the textView and keyboard to be exactly as they were when the app was sent to the background. What might cause the textView to go back to its baseline position? I'm running through the view controller with breakpoints and, so far, have had no luck finding anything.
EDIT: You don't actually have to send the app all the way to the background. Just starting the touch gesture to send the app to the background (dragging the virtual home bar up) and letting go will remove the textView (also removes an inputAccessoryView if there is one).
EDIT: Here is the slow motion screen recording demonstrating the issue:
I added an Alert view, asking for user input, at the start of my app. The app works fine without the Alert view. But with the code for the Alert view added, part of the UI is blacked out after hitting the 'ok' button on the alert.
I'm not well versed in ios, but is there a good way to delay the app from running until the Alert (text input) is completed (ok button pressed). This might avoid whatever is causing the screen to go black in one section. Apparently the app is executing while the alert is active, and the alert is affecting the UI. Basically, I am asking the user to input their phone number via an alert that will be used later in the app.
When alert view is shown on screen, getting back ground dimmed (reduced alpha) is a normal thing and is practiced by iOS.
However, if you feel some part of the code you want to run only on tap on OK button on alert, move that method call to OK button action handler.
iOS 7 and XCode 5.
I have a textview with a phone number that can be touched to make a call.
I have implemented the UIGestureRecognizer with a selector, but this "doesn't work" (more on that below)
The issue is this:
When I tap on the phone number on the device I get an alertview prompt "(phone) Cancel/Call"
Here's what I want to do:
I want to capture (for data collection purposes, not real behavior) whenever the user pushes the "call" button in the alertview.
The reason why the UIGestureRecognizer "doesn't work" is because the selector method only gets called if the user taps on the cancel button or taps on the phone link multiple times. Both of these cases are useless for me.
Any suggestions?
Note: I dont want to make a button to place the call since by doing this the OS takes me back to the phone app after the all instead of my app, like the textview does.
My app must sometimes show an UIAlertView when the Home button or the locking button is pushed or when the notification center is shown.
I show the Alert from the applicationWillResignActive delegate's method and everything is ok when home button is pushed or when notificacion center is shown. But there is a problem if the button which is pushed is the locking button (on/off button).
In that case, the Alert is not shown when I return to the app (if I used the Home button it is there). I don't do anything else in other AppDelegate methods which are executed. Also, then, when I show a new Alert (any Alert in the app) the Alert which hasn't been shown when I returned is shown after I dismiss the new one.
Please, could anybody help me?
Thanks in advance.
THE EASY, GIVE ME REP ANSWER:
When the app is put into the background, the app is suspended. Part of this process is closing open alert views.
THE I ACTUALLY KNOW WHAT I'M TALKING ABOUT ANSWER:
The logic behind this is that when the user hits the home button when an alert is displayed, they might be going to look for information on how to answer the alert. However, when the sleep button is pressed, the user has stopped using the device altogether. Apple knows that if they unlock thier device again 3 hours later and see something like Confirm Deletion, they will have absolutely no idea what they were just doing and what to do now.
This is known to cause a serious condition known as what-in-the-world-am-I-supposed-to-do-now-itis. Symptoms of this condition include hitting the round button at the bottom of the screen and subsequently holding on your app icon until it jiggles. They then hit the little 'x' button. This is not good for developer's pockets.
In my app I am having a customer info form on which there are a number of text fields I have used, now when a user edits any field I need to move whole view up so that the editing text field won't get under iPad's internal keyboard and this is working fine.
Now the client wants to use external Bluetooth keyboard for filling this form. Once this external keyboard is connected with iPad then in the app when editing any text field won't show internal keyboard as the external is connected and in this case whole view needs to be on the page and no need to move it up.
But when I edit text field it still goes up without showing internal keyboard on the screen and this leaves half of the screen blank as it moves whole view up.
For this I have tried some ways like enabling internal keyboard show/hide notifications but these notification only gets called when external keyboard is not connected and this is not helping me.
Also have tried with ExternalAccessory framework, but it wont detect the bluetooth connected keyboard also tried with EADemo to detect external keyboard and its not detecting external keyboard but it detects credit card swiper connected trough dock.
If anyone here has gone through this functionality or knows anything related with this, then please let me know.
#SpySudhir --
Logic A:
have a bool variable in some file which will return yes/no value when the keyboard is external or internal.
On the basis of the bool value returned call the animation function.
Logic B:
Listen to the keyboard notification using NSNotificationCenter.
Notifications like will,show,hide notification put an NSLog over their and see which one of them is getting called.
If external board is connected the willShow method does not gets called. so in this case can we can do some work around and set the bool value to no or we can have a counter and check it every time if its value is increased by one or is same something like this.
You should not move the view up when field gets focus - you should only move the view up as a response to a UIKeyboardDidShowNotification. The system takes care of the rest for you.