XCode 14 Beta中的NavigationStack的身体渲染问题
在以下代码中,contentView
的背景颜色在两秒钟后不会更改。
struct ContentView: View {
@State private var bool: Bool = false
var body: some View {
NavigationStack(root: {
Group(content: {
if bool {
Color.red
} else {
Color.blue
}
})
.onAppear(perform: {
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
print(">>>")
bool = true
})
})
})
}
}
root:{用navigationView(content:content:{
但是,当替换navigationStack ( 使用Xcode
14.0
beta 2(14a5229c
),并在iOS 16.0
上运行它(20A5303I
)。
In the following code, background color of the ContentView
doesn't change after two seconds.
struct ContentView: View {
@State private var bool: Bool = false
var body: some View {
NavigationStack(root: {
Group(content: {
if bool {
Color.red
} else {
Color.blue
}
})
.onAppear(perform: {
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
print(">>>")
bool = true
})
})
})
}
}
However, when replacing NavigationStack(root: {
with NavigationView(content: {
, the problem disappears.
Is anyone facing the same problem, or am I doing something wrong? I am using XCode 14.0
beta 2 (14A5229c
), and running it on iOS 16.0
(20A5303i
). Issue happens on both, simulator and physical device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谁知道...可能是故意的,这可能是一个错误,向苹果提交反馈。
同时,这里是一个解决方法,
在这种情况下,不再需要使用Xcode 14 / ios 16 *btw,< / code>组< / code>进行测试。
Who knows... may be it is intentional may be it is a bug, submit feedback to Apple.
Meanwhile here is a workaround, tested with Xcode 14 / iOS 16
*BTW,
Group
is not needed anymore in such cases.