Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions IQKeyboardToolbarManager/Classes/IQKeyboardToolbarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import Combine
super.init()

addTextInputViewObserver()
addBecomeActiveObserver()
addKeyboardDidShowObserver()

// (Bug ID: #550)
// Loading IQKeyboardToolbar, IQTitleBarButtonItem, IQBarButtonItem to fix first time keyboard appearance delay
Expand Down Expand Up @@ -153,21 +153,20 @@ private extension IQKeyboardToolbarManager {
storage.removeAll()
}

private func addBecomeActiveObserver() {
let beginEditingNotificationNames: [Notification.Name] = [
UIApplication.didBecomeActiveNotification
]

for notificationName in beginEditingNotificationNames {
NotificationCenter.default.publisher(for: notificationName)
.sink(receiveValue: { [weak self] info in
guard let self = self else { return }

// In SwiftUI View's when app comes from background to foreground
// The inputAccessoryView was getting removed in iOS 26. So forcing to reload.
self.reloadInputViews()
})
.store(in: &storage)
}
private func addKeyboardDidShowObserver() {
let notification = UIResponder.keyboardDidShowNotification

NotificationCenter.default
.publisher(for: notification)
.compactMap { [weak self] _ in self?.textInputView }
.sink { [weak self] textInputView in
self?.showLog("Keyboard did show, reloading input views for \(textInputView)")
// The keyboard may reappear after being hidden due to backgrounding, navigation,
// modal presentation, or window overlay – without a new beginEditing event.
// Reloads the toolbar exactly when the keyboard is ready,
// fixing the missing inputAccessoryView issue (iOS 26 and above).
self?.reloadInputViews()
}
.store(in: &storage)
}
}