简体   繁体   English

奇怪的蓝色轮廓 SwiftUI List in EditMode on iOS 16

[英]Weird blue outline on SwiftUI List in EditMode on iOS 16

After updating to Xcode 14 and iOS 16 on my devices the lists in my app seems broken in a number of ways.在我的设备上更新到 Xcode 14 和 iOS 16 后,我的应用程序中的列表似乎在很多方面都被破坏了。 The problem I'm describing here seems to occur when using a List in a NavigationView that contains two views.我在这里描述的问题似乎是在包含两个视图的NavigationView中使用List时发生的。 When the List elements has a custom background using .listRowBackground and EditMode is activated, the selected row sometimes get a blue outline.List元素具有使用.listRowBackground的自定义背景并且激活了EditMode时,所选行有时会出现蓝色轮廓。 It only occurs when I'm running on iPad (regular mode).它仅在我在 iPad(常规模式)上运行时发生。 It does not follow the selection of rows but seem to appear randomly over the list.它不遵循行的选择,但似乎随机出现在列表中。 Anyone else encountered this and have come up with a fix?还有其他人遇到过这个问题并提出了解决办法吗? Seems like a total bug to me.对我来说似乎是一个完整的错误。 I will report it to Apple if I'm not getting explanation here.如果我在这里没有得到解释,我会向 Apple 报告。

在此处输入图像描述

The code to reproduce the error:重现错误的代码:

struct ContentView: View {

    let myStrings = ["string1", "string2", "string3"]
    @State var selection = Set<String>()

    var body: some View {
        NavigationView {
            List(selection: $selection) {
                ForEach(myStrings, id: \.self) { myString in
                    Text(myString)
                        .listRowBackground(Color(UIColor.secondarySystemGroupedBackground))
                }
            }
            .listStyle(.insetGrouped)
            .toolbar {
                EditButton()
            }
            EmptyView()
        }
    }
}

I'm running Xcode 14.2 and iPadOS 16.2.我正在运行 Xcode 14.2 和 iPadOS 16.2。

EDIT: Seems like it only appears on iPad when having an external keyboard connected.编辑:似乎它只在连接外部键盘时出现在 iPad 上。

If you custom-color either the listRowBackground or the listRowSeparator, you'll get this result.如果您自定义 listRowBackground 或 listRowSeparator 的颜色,您将获得此结果。 It's SwiftUI showing the user what item was selected. SwiftUI 显示用户选择了什么项目。

Remove the listRowBackground modifier and you'll see the list item itself colored in the tintColor, rather the the list item being bordered in the tintColor.删除 listRowBackground 修饰符,您将看到列表项本身在 tintColor 中着色,而不是在 tintColor 中加边框的列表项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM