gpt4 book ai didi

ios - swift 用户界面 : Input Field Keyboard animation causing other views in tab view to animate

转载 作者:行者123 更新时间:2023-12-05 02:42:55 27 4
gpt4 key购买 nike

与我的 TabView 内的 View 中的输入字段交互导致我的其他 View 在出现时出现奇怪的动画。此外,导航栏没有按应有的方式隐藏。

我已经确定它是一个输入字段 + TabView 问题,因为:

  • 此问题不会出现在模拟器上(键盘不会向上推)。
  • 如果用户在与输入字段交互之前导航到其他选项卡 View ,则不会发生这种情况。
  • 当我将选项卡 View 的内容放在另一个 View 中并导航到它时,不会发生这种情况。

我研究了一些解决方案,但没有成功:有没有办法覆盖键盘动画?有没有办法在选项卡 View 加载时强制选项卡 View View “出现”?有没有办法阻止其他 TabView subview 受到其他 TabView View 更改的影响

标签查看代码

        TabView (){
ViewA()
.tabItem {
Image("viewa").renderingMode(.template)
Text("viewa")
}

ViewB()
.tabItem {
Image("viewb").renderingMode(.template)
Text("viewb")
}
ViewC()
.tabItem {
Image("viewc").renderingMode(.template)
Text("viewc")

}
ViewD()
.tabItem {
Image("viewd").renderingMode(.template)
Text("viewd")
}

}

在选项卡 View 的 subview 中,动画被应用到包含我的项目的 VStack,就像这样。

VStack{
items...
}.animation(.easeInOut)

此代码用于隐藏导航:

        .background(NavigationConfigurator { nav in 
nav.hidesBarsOnSwipe = true
})

预期行为:

enter image description here

与输入字段交互时的行为:

enter image description here

最佳答案

看来这是 TabView 和键盘的持续错误。在解决此问题之前的临时修复是将 VStack 转换为 LazyVStack,以便在必要时才加载 View 。

参见:OnAppear calls unexpectedly when Keyboard Appears in SwiftUI

关于ios - swift 用户界面 : Input Field Keyboard animation causing other views in tab view to animate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67213145/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com