How to get real time keyboard frame while using keyboardDismissMode = .interactive - ios

so my situation is as follows: I have a collectionView which loads chat messages, and an inputBarView that contains a textview, a send button, and some buttons (text, photo, etc). Currently, I'm using notifications to track the keyboard as it appears and hides, and modify the inputBarView's bottom constraint to keep it on top of the keyboard. What I'm trying to implement is for the user to be able to swipe away the keyboard akin to how facebook an imessage do it (gif 1).
Gif 1 - the goal
Currently, if I set the keyboardDismissMode to .interactive and keep the notification handler, the keyboard follows the user's finger as it slides down (as it's supposed to), but the inputBarView doesn't move until the keyboard is hidden (gif 2).
Gif 2 - the issue
I have searched for a solution for this for the past couple of days but nothing has worked so far. There are multiple questions about this exact issue here, but they're all either outdated, workaround hacks, or pod recommendations. Is there way to track the keyboards frame while dismissing it using .interactive?

Related

Custom Keyboard Accessory view input

I have created a custom accessory view to supplement the standard Apple alpha iOS keyboard.
The purpose is to add a line of numeric keys to prevent flipping back and forth between keyboard views. At first, I created a toolbar and loaded it with a set of 0 - 9 titled buttonItems and it functioned quite well. However, it looked terrible, not at all like the alpha keys despite adding a rounded rect background image to each key because the system apparently prevents customizing font size and button spacing inside the stack view of the toolbar. Therefore, I created a UIView xib and loaded it with a stackView full of customized numerical buttons. When I add the UIView as the accessory view it looks pretty darn close to the rest of the Apple Alpha keyboard. The issue now is that the touch-up events go to the UIView class of the accessory view. Is there a clever, efficient way to have the button presses in the accessory emulate the std keyboard feeding into TextField: shouldChangeCharactersIn? I could package the button presses into a local notification event to get it into the class holding the textField but that seems terribly inelegant! Any suggestions would be greatly appreciated. Stay Safe!
Not the best answer, but I did implement notification on key button press with an observer in the main view class. The observer does a TextField.insertText which is suboptimal since I will need to refactor the several hundred lines of code that performs real-time language translation in the shouldChangeCharacters methods. Ah well.

Accessibility voiceover single swipe gestures in Swift IOS

I am working on the IOS application, related to voice over, my Question is : When accessibility voice over was enabled how can i get the swipe gestures left, right, top and down, what re the function for detecting these in swift?
First of all, you need to let VoiceOver know that about your view (or another element). So if you are in a view controller, this should work: self.view.isAccessibilityElement = true
Second, you need to let VoiceOver know that your view will handle user interactions on its own: self.view.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction. After that your view should start getting gestures notifications.
Here's another relevant answer: https://stackoverflow.com/a/20712889/2219578
It isn't possible to catch the left, right, top and bottom VoiceOver gestures : I've seen neither a protocol nor a kind of notification for this.
However, you can detect a scrolling action and be aware of the element focus provided by VoiceOver.

Attaching a custom alert view above the iOS keyboard

I'm trying to design (a "properly designed," not "hack") custom alert view. The view should attach itself to the top of the keyboard; sliding up with the keyboard (if there is an alert) or being hidden (if there is no alert).
The view should always "stick" to the keyboard... including, for instance, when the keyboard hides. In that case, the view should slide right down, out of sight, along with the keyboard.
Here's an example of what I'm trying to achieve (with an active alert):
I have originally thought about subclassing UIAlertView, but it looks like that is not recommended. And, after experimenting a bit, this is clearly a tricky task. I've got an alert that shows up but, it turns into problems staying in sync with the keyboard, and I haven't found a way to make it "track" with the motion of the keyboard... not smoothly.
Any ideas?
You can achieve this with inputAccessoryView of UITextField and UITextView. See Custom Views for Data Input chapter in Apple's "Text Programming Guide for iOS" for more information.
For example, a very simple red bar above the keyboard can be added with the following code:
let keyboardAlertView = UIView(frame:CGRectMake(0,0,320,44))
keyboardAlertView.backgroundColor = UIColor.redColor()
textField.inputAccessoryView = keyboardAlertView

iOS 7 Messages: Fixed UITableView while still being able to bring up textfield?

I've done a lot of research before asking this question and haven't found a thorough answer. Forgive me if it's been asked somewhere else. I have been working on a messaging app for a few weeks now. Taking into account a typical messaging app (text field at bottom for user input with a table to store messages, pictures etc.) I understand that when the keyboard is shown the whole view must be pushed up to get the UITextField above the keyboard to show user input. I examined the native messages app on iOS 7 however, and I noticed that when the keyboard is shown ONLY the UITextField is moved up from the bottom of the view and the table view stays fixed (at least that's how I believe they are doing it). I know the table stays at a fixed point because when you scroll down to older messages at the top of the table, the most recent messages can be seen blurred behind the keyboard and can go all the way down the view itself while still having the keyboard visible. My question here is: is it possible to have a fixed table view while still being able to bring the text field up above the keyboard to show user input? In other words, is it possible to move just the text field up without having to move the whole view itself up?
Why not set the inputAccessoryView of the original textfield to be another textfield?
self.textFieldAtBottomOfView.inputAccessoryView = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 250, 30)];
that way you'll get a textfield that floats above the keyboard. You might need to style it to look like your first textfield and the user would think that it moved up above the keyboard on focus.

iOS UISlider not moving when I swipe, even though other UI elements are fine

I've created a simple xib file with three buttons and a UISlider.
When I start the app on my phone I'm able to tap the buttons no problem, but the UISlider is locked and doesn't move..
However if I keep trying to move it with my finger it eventually scrolls left and right fine, but only after about a minute of furious screen swiping..
I thought it might be because it was hidden behind something onscreen (not that there's anything for it to hide behind) so I did 'arrange -> send to front', but this doesn't help.
Does anyone know why it might be doing this?

Resources