Why use many DispatchQueue.main.async when few do trick?
This commit is contained in:
parent
733d50b642
commit
cf63384dce
|
@ -149,20 +149,18 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
|
|||
context.coordinator.didChange = textDidChange
|
||||
context.coordinator.uiState = uiState
|
||||
|
||||
if becomeFirstResponder {
|
||||
DispatchQueue.main.async {
|
||||
// wait until the next runloop iteration so that SwiftUI view updates have finished and
|
||||
// the text view knows its new content size
|
||||
DispatchQueue.main.async {
|
||||
self.textDidChange(uiView)
|
||||
|
||||
if becomeFirstResponder {
|
||||
// calling becomeFirstResponder during the SwiftUI update causes a crash on iOS 13
|
||||
uiView.becomeFirstResponder()
|
||||
// can't update @State vars during the SwiftUI update
|
||||
becomeFirstResponder = false
|
||||
}
|
||||
}
|
||||
|
||||
// wait until the next runloop iteration so that SwiftUI view updates have finished and
|
||||
// the text view knows its new content size
|
||||
DispatchQueue.main.async {
|
||||
self.textDidChange(uiView)
|
||||
}
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
|
|
Loading…
Reference in New Issue