InputBarAccessoryView
InputBarAccessoryView copied to clipboard
iOS 14 Delayed Display
Bug Description On iOS 14 devices, constraints on InputBarAccessoryView's leftStackView, rightStackView, and inputTextView fail to load immediately.
This is evident in the inputTextView's placeholder and left & right buttons not appearing until well after the view has loaded.
It seems like iOS 14 introduced some sort of layout delay that doesn't play well with how constraints are activated and deactivated in InputBarAccessoryView. This issue doesn't exist on iOS 13.
To Reproduce
Note: For some reason, this bug only happens if there isn't much activity on the main thread. For example, if a tableView has many cells and calls reloadData on viewDidLoad, this input bar loads correctly. However if the tableView has 1 or 2 cells, there's bug appears.
- Change the sample projects number of sample messages to zero, such that
numberOfRowsInSection
returns 0.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return conversation.messages.count
}
- Run the project on an iOS 14 device or simulator and press the iMessage input bar without any customizations. You should see a delay in the loading.
Expected behavior There should not be a delay when loading an InputBarAccessoryView. Behavior should be like iOS 13.
Screenshots
Environment
- Version: 5.1.0
- iOS 14 and above
- Swift 5.3
- iPhone 12 Pro (iOS 14.2.1), iPhone 7 (iOS 13.4 - No Problem)
- Is the issue you're experiencing reproducable in the example app? - Yes.
Current Workaround
Make an extra performLayout call on the main thread on iOS 14 devices right after initializing the input bar. Careful not to call this on iOS 13 (and below) devices as it'll produce the same delay as described above for iOS 14 devices. Not sure why. The code below should be a temporary workaround.
if #available(iOS 14, *) {
let yourStackViewWidth = 52
DispatchQueue.main.async { self.setRightStackViewWidthConstant(to: yourStackViewWidth, animated: false) }
}
@JCsplash thanks for the walk around for now
Same issue for me too, coming from MessageKit (the workaround worked for me though)
Issue came back in OS15...
@yarodevuci Workaround still works?
@yarodevuci Workaround still works?
@Kaspik nope. Sometimes it does sometimes no
I'm not seeing this on iOS 16. @yarodevuci is this issue persisting for you on iOS 15?