ios - SwiftUI IPhone TextFields spanning greater than screen jumping, standard behaviour?
问题描述
I have a screen layout where I have 2 text fields with content that pushes then last Textfield out of the screen: Textfield .... TextField
When I enter data, in the top Textfield, and the click on the bottom textfield, the screen jumps back to the top TextField. Even though the focus is now on the bottom textfield. Think this would be 'standard' behaviour or a 'bug'.
As code is straight forward:
import SwiftUI
import CoreData
struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext
@State var test = ""
@State var test1 = ""
@State var test2 = ""
@State var test3 = ""
@State var test4 = ""
@State var test5 = ""
@State var test6 = ""
@State var test7 = ""
@State var test8 = ""
@State var test9 = ""
@State var test10 = ""
@State var test11 = ""
@State var test12 = ""
@State var test13 = ""
@State var test14 = ""
@State var test15 = ""
@State var test16 = ""
@State var test17 = ""
@State var test18 = ""
@State var test19 = ""
var body: some View {
NavigationView {
ScrollView {
VStack{
TextField("Test", text: $test, onEditingChanged: {
edit in
print("Hello")
})
Text("Hello")
.font(.system(size: 90))
Text("Hello")
.font(.system(size: 90))
Text("Hello")
.font(.system(size: 90))
Text("Hello")
.font(.system(size: 90))
Text("Hello")
.font(.system(size: 90))
Text("Hello")
TextField("Test9", text: $test11, onEditingChanged: {
edit in
print("Hello")
})
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
}
}
Is this standard behaviour?
I would like the focus to change to the field selected not the field data has been entered.
解决方案
推荐阅读
- sql-server - 在 SQL Server 中按两列分组
- python - 流图,如 earth.nullschool.net
- regex - 如何使用正则表达式通过 ABBYY FineReader 改进 OCR
- reactjs - 渲染顺序问题(反应)
- python-3.x - Modify a protege file from python
- javascript - 网格中只有一列的滚动条
- xampp - Ampps 和 xampp 安装在同一个远程服务器中
- html - Adding an id or class to content of a page-template dynamically in WordPress
- laravel - GuzzleHttp 客户端:CURL 错误 3:
畸形 - ios - 当主线程使用增加时,IOS音频线程CPU使用率下降