nathantannar4 / InputBarAccessoryView

A simple and easily customizable InputAccessoryView for making powerful input bars with autocomplete and attachments
MIT License
1.17k stars 229 forks source link

The inputBarAccessoryView is shown along with the UIAlertController, when presented as `.actionSheet`. #235

Open chauhan130 opened 2 years ago

chauhan130 commented 2 years ago

Describe the bug The inputBarAccessoryView is shown along with the UIAlertController, when presented as .actionSheet, works fine for .alert.

To Reproduce Steps/code to reproduce the behavior:

  1. Open up the example project from MessageKit.
  2. Go to Advanced Example.
  3. Tap on the InputBarAccessoryView's text view to open the keyboard.
  4. When the keyboard is open, tap on the camera icon.

Expected behavior The keyboard is hidden and the action sheet is presented.

Screenshots

Environment

Additional context Add any other context about the problem here. The issue happens with iOS 16 only. Works fine with the latest iOS 15.

IAmConorNolan commented 2 years ago

Experiencing this issue too. Did you find any workaround?

chauhan130 commented 2 years ago

@IAmConorNolan, as a temporary workaround, before presenting the alert controller, I do view.endEditing(true), also overrode canBecomeFirstResponderof the viewController and return true only if the current view controller is at the top, like there is no any view controller presented and the in the navigation stack, it is the front most view controller.

ekazaev commented 2 years ago

@IAmConorNolan @chauhan130 Experiencing the same issue. Also the inputAccessoryView appears slower than the animation of the view controller itself. Is it like completely broken in IOS 16?

IAmConorNolan commented 2 years ago

@ekazaev +1, I'm also experiencing this same lag when transitioning to a view controller showing the inputBarAccessoryView.

nathantannar4 commented 2 years ago

I think this is an issue MessageKit would have to address. InputBarAccessoryView doesnt track the UIViewController its attached to.

MessagesViewController should probably not be the first responder if its presenting another UIViewController.

As a workaround, you could override its canBecomeFirstResponder and ensure you resignFirstResponder before presenting

JCsplash commented 1 year ago

Having the same issue. @nathantannar4 is there a more robust fix now or should we still use the workarounds?

JCsplash commented 1 year ago

Seems like iOS 16's deprecating of UIRemoteKeyboardWindow is causing this issue. The code below works great. presentedViewController covers UIAlertController as well as any UIViewController with modalPresentationStyle that's not full screen. Hope this helps anyone else with this issue.

    override var canBecomeFirstResponder: Bool{
        if #available(iOS 16, *) {
            // UIRemoteKeyboardWindow was deprecated in iOS 16 and caused new behavior.
            // Fixes bug where inputAccessoryView displays above actionsheet or panel.
            print("canBecomeFirstResponder: \(!isInputBarHidden && presentedViewController == nil)")
            return preIOS16CanBecomeFirstResponderFlag && presentedViewController == nil
        }
        else {
            return preIOS16CanBecomeFirstResponderFlag
        }
    }
gerchicov-vg commented 2 months ago

@JCsplash what if I don't own this view controller (inner ads view controllers)?