Skip to content

Instantly share code, notes, and snippets.

@kkebo
Created June 6, 2020 17:24
Show Gist options
  • Save kkebo/49c614220af0db81771ada61a2aa1f8d to your computer and use it in GitHub Desktop.
Save kkebo/49c614220af0db81771ada61a2aa1f8d to your computer and use it in GitHub Desktop.
SwiftUI TextField 日本語入力問題
import PlaygroundSupport
import SwiftUI
final class ContentViewModel {
@Published var text = ""
}
extension ContentViewModel: ObservableObject {}
struct ContentView {
@ObservedObject var viewModel = ContentViewModel()
@State var text = ""
}
extension ContentView: View {
var body: some View {
VStack {
TextField("State", text: self.$text)
TextField("ObservedObject", text: self.$viewModel.text)
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
@kkebo
Copy link
Author

kkebo commented Jun 6, 2020

@State なプロパティをバインドしたときは問題ないけど、ObservableObject@Published なプロパティをバインドしたときだけ日本語入力ができない問題が発生する。(iPadOS 13.4, 13.5, 13.5.5 Developer Beta 1 で確認)
再現動画: https://twitter.com/_kebo/status/1269323076912611328?s=21

@kkebo
Copy link
Author

kkebo commented Jun 28, 2020

iPadOS 14 Developer Beta 1 でも変化なし。

@kkebo
Copy link
Author

kkebo commented Aug 20, 2020

iPadOS 14 Developer Beta 5 で修正されていることを確認.(iOS SDK 13 & iOS SDK 14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment