在列表(SwiftUI)中导航后,所选列表行的背景保持灰色(选中). iOS14 + Xcode12 [英] Selected list row's background remains grey (selected) after navigating back in List (SwiftUI). iOS14 + Xcode12

查看:127
本文介绍了在列表(SwiftUI)中导航后,所选列表行的背景保持灰色(选中). iOS14 + Xcode12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从详细视图返回后,选定的行仍为灰色.仅在iOS 14上同时发生在模拟器和真实设备上.有人知道如何删除它,使其行为与在iOS 13上相同(不会保持选中状态)吗? 这是项目中的唯一代码. (没有其他导航或任何导航).

The selected row remains grey after navigating back from the detail view. Happening both on simulator and real device, only on iOS 14. Does anyone know how to remove it so it behaves the same as on iOS 13 (doesn't remain selected)? This is the only code in the project. (No other navigation's or anything).

let items = ["item1", "item2"]

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                Text("Hello")
                
                List(items, id: \.self) { item in
                    NavigationLink(destination: Text(item)) {
                        Text(item)
                    }
                }
                .listStyle(PlainListStyle())
            }
        }
//        .navigationViewStyle(StackNavigationViewStyle()) // didn't solve the problem
    }
}

外观是

推荐答案

我在使用StackNavigationViewStyle()时遇到了同样的问题. 该问题通过使用DefaultNavigationViewStyle()为我自己解决了.

I had the same problem as soon as I used StackNavigationViewStyle(). The issue resolved itself for me by using DefaultNavigationViewStyle().

这篇关于在列表(SwiftUI)中导航后,所选列表行的背景保持灰色(选中). iOS14 + Xcode12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆