inputAccessoryView animating down when alertController (actionSheet) presented
The InputAccessoryView
sits outside of your ViewController's hierarchy - it's contained in the UITextEffectsWindow
whose rootViewController is a UIInputWindowController
. Similarly the keyboard is contained in UIRemoteKeyboardWindow
and its own UIInputWindowController
.
So, if we present the alert from the topmost window or higher (UITextEffectsWindow
or UIRemoteKeyboardWindow
), it won't resign first responder.
The simplest solution I've found is:
let topViewController = UIApplication.shared.windows.last!.rootViewController!
topViewController.present(alert, animated: true, completion: nil)
Ideally you would safely handle those optionals. A potentially better solution (I've seen some console errors from the previous solution) would be to create a new UIWindow with a higher WindowLevel, make it the key window and visible, and present the alert from there.
Leaving inputAccessoryView visible after keyboard is dismissed iOS8?
iOS8 has a retain cycle with the inputAccessoryView. Here's a good post that seems to have a good workaround:
http://derpturkey.com/uitextfield-docked-like-ios-messenger/
animate text from inputAccessoryView to tableView like iOS 11 messages app
I believe this animation works like this:
- When you type the text and press send, a new text bubble is added to the end of the messages table view by using tableView.insertRows(at: [IndexPath], with: UITableViewRowAnimation). This will add the bubble and animate the tableview upwards.
- At the same time, a floating bubble view is created and placed over the text input view such as its width spans the leading edge of the text input view and the trailing edge of the new chat bubble that was inserted into the table view.
- The floating bubble view is very quickly and simultaneously animated in two directions: its width changes until it arrives at the same width as the new bubble on the tableView and its y position changes at the same speed as the added chat bubble scrolls up on the tableView.
- Then, when the animation finishes, the floating bubble is removed.
If you synchronize the floating bubble animation with the chat bubble really well it will seem as if the input text "became" the chat bubble.
I believe they used this create overlapping view -> animate -> remove overlapping view flow because if you pay close attention to the chat bubble during the animation, just at the end it looks like the booble changes just a little tiny bit, as if the floating bubble wasn't perfectly aligned.
Hide status bar even when an alert is presented
As UIAlertController
is now a full-fledged UIViewController
, you should be able to subclass it and add the same method to the new subclass. Then instanciate your subclass instead of a plain UIAlertController
.
Untested, but that should do the trick.
Related Topics
Mpmovieplayercontroller Stops Playing After 5 Seconds - Swift
How to Automatically Create an Initializer for a Swift Class
Setting Uiimageview Image Affects Layout Constraints
How to Draw Geojson in Apple Maps as Overlay Using Swift 3
How to Access Index of Tabbar Item Using Swift
How to Store Array in Nsuserdefault in Swift
Avplayer Not Full Screen in Landscape Mode Using iOS Swift
Swift Extension and Enum for Color Schemes
Self Sizing Uitextview Till Specific Height
Avcapturestillimageoutput VS Avcapturephotooutput in Swift 3
Openurl in Appdelegate Conversion Error Nsstring -> String (Swift & iOS8)
How to Change Searchbar Border Color
How to Run a Task in Swift on a Particular Date-Time in Background Either Application Is on or Off