Aus*_*n E 3 uitabbarcontroller swift swiftui uihostingcontroller
I have the below series of controllers and views. However, when I use the navigation link on the MoreView it changes the tabBarItem.title value. For instance it will say more, but when the privacy policy button is clicked and the user is navigated to policy view, the title in the tab bar changes to whatever is in .navigationBarTitle() or if non is provided, an empty string! How do I avoid this? I want the tab bar title to be static
UITabBar -> UINavigationController -> MoreViewController(UIHostingController) -> MoreView(SwiftUI)
更多查看
List {
Section(
header: Text("ABOUT"),
footer: Text(aboutFooter)
.font(.caption)
) {
NavigationLink(destination: WebView(
request: URLRequest(url: URL(string: "https://www.websitepolicies.com/policies/view/ng0sNvAJ")!)
)//.navigationBarTitle(Text("Privacy Policy"))
) {
Text("Privacy Policy")
}
Text("Attribution")
}
}
.listStyle(GroupedListStyle())
.environment(\.horizontalSizeClass, .regular)
Run Code Online (Sandbox Code Playgroud)
这将是 iOS 中的一个错误。请向 Apple 提交错误报告。
我刚刚发现了解决此问题的方法:
创建一个自定义子类UINavigationController并将其用作包含您的MoreViewController.
class WorkaroundUINavigationController: UINavigationController {
override var title: String? {
get { tabBarItem.title }
set { navigationItem.title = newValue }
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
535 次 |
| 最近记录: |