[英]SwiftUI: navigation bar shows title for first list item, otherwise shows “Back”
I have basic list and detail views set up as shown below.我设置了基本列表和详细视图,如下所示。 The problem is that the first detail view shows "< Inbox" as the back button while the other rows show "< Back".
问题是第一个详细视图显示“< Inbox”作为后退按钮,而其他行显示“< Back”。 I've tried various options and places for
.navigationBarTitle
but haven't found any way to solve this.我已经尝试了
.navigationBarTitle
的各种选项和位置,但还没有找到解决此问题的任何方法。
Main / list view:主/列表视图:
var body: some View {
NavigationView {
List {
ForEach(userData.message) { messageSection in
Section(header: Text(messageSection.id)) {
ForEach(messageSection.messages) { message in
NavigationLink(destination: MessageDetail(message: message)) {
MessageRow(message: message)
}
}
}
}
}.navigationBarTitle(Text("Inbox"), displayMode: .inline)
}
}
Detail view:详细视图:
var body: some View {
ScrollView {
VStack {
...
}
}.navigationBarTitle(Text("\(self.message.title) (\(self.message.preview))"), displayMode: .inline)
}
When the title is too long to display in the space allocated for the left bar button, the system uses "Back" as the button title instead.当为左栏按钮分配的空间显示标题过长时,系统使用“返回”作为按钮标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.