forked from shadowfacts/Tusker
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.didChange = textDidChange
|
||||||
context.coordinator.uiState = uiState
|
context.coordinator.uiState = uiState
|
||||||
|
|
||||||
if becomeFirstResponder {
|
// 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 {
|
DispatchQueue.main.async {
|
||||||
|
self.textDidChange(uiView)
|
||||||
|
|
||||||
|
if becomeFirstResponder {
|
||||||
// calling becomeFirstResponder during the SwiftUI update causes a crash on iOS 13
|
// calling becomeFirstResponder during the SwiftUI update causes a crash on iOS 13
|
||||||
uiView.becomeFirstResponder()
|
uiView.becomeFirstResponder()
|
||||||
// can't update @State vars during the SwiftUI update
|
// can't update @State vars during the SwiftUI update
|
||||||
becomeFirstResponder = false
|
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 {
|
func makeCoordinator() -> Coordinator {
|
||||||
|
|
Loading…
Reference in New Issue