Inputaccessoryview Animating Down When Alertcontroller (Actionsheet) Presented

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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



Leave a reply



Submit