swiftui-navigationlink

Using NavigationLink in Menu (SwiftUI)

本小妞迷上赌 提交于 2021-02-19 02:28:27
问题 Can you use a NavigationLink as a Menu 's item in swiftUI? It seems to do just nothing: Menu { NavigationLink(destination: Text("test1")) { Text("item1") } NavigationLink(destination: Text("test2")) { Text("item2") } } label: { Text("open menu") } In case it is meant to not work as tried above, is there an alternative way of achiving the intended reult? 回答1: NavigationLink should be inside NavigationView hierarchy. The Menu is outside navigation view, so put buttons inside menu which activate

SwiftUI - destination of NavigationLink creates view with extra space

天大地大妈咪最大 提交于 2021-02-11 14:15:03
问题 I've whittled my login page down to a single NavigationLink that leads to a List view as its destination. The problem, as you can see in the image below, is that instead of the nicely spaced title on the left, I get the huge space as shown on the right. Both views are the same, but the one on the right is the preview of the page as it was designed. The image on the left is the preview of the page after coming from the login screen. struct ContentView: View { var body: some View {

SwiftUI - destination of NavigationLink creates view with extra space

♀尐吖头ヾ 提交于 2021-02-11 14:12:52
问题 I've whittled my login page down to a single NavigationLink that leads to a List view as its destination. The problem, as you can see in the image below, is that instead of the nicely spaced title on the left, I get the huge space as shown on the right. Both views are the same, but the one on the right is the preview of the page as it was designed. The image on the left is the preview of the page after coming from the login screen. struct ContentView: View { var body: some View {

SwiftUI NavigationLink in list

旧时模样 提交于 2021-02-11 04:33:29
问题 I tried to do a list which have image and a navigation link inside. In iOS 14.1 everything work fine but after I update my iOS to 14.2, something break. In the list while the user click the big image there will be a action sheet pop out, while the user click a systemImage it will trigger a navigation link. However, when I update to iOS 14.2, no matter what I clicked, it will trigger the NavigationLink. Can someone explain to me why will this happened and how to solve? Here is the sample code

SwiftUI NavigationLink in list

喜夏-厌秋 提交于 2021-02-11 04:32:07
问题 I tried to do a list which have image and a navigation link inside. In iOS 14.1 everything work fine but after I update my iOS to 14.2, something break. In the list while the user click the big image there will be a action sheet pop out, while the user click a systemImage it will trigger a navigation link. However, when I update to iOS 14.2, no matter what I clicked, it will trigger the NavigationLink. Can someone explain to me why will this happened and how to solve? Here is the sample code

SwiftUI NavigationLink in list

痞子三分冷 提交于 2021-02-11 04:30:15
问题 I tried to do a list which have image and a navigation link inside. In iOS 14.1 everything work fine but after I update my iOS to 14.2, something break. In the list while the user click the big image there will be a action sheet pop out, while the user click a systemImage it will trigger a navigation link. However, when I update to iOS 14.2, no matter what I clicked, it will trigger the NavigationLink. Can someone explain to me why will this happened and how to solve? Here is the sample code

Remove space NavigationTitle but not the back button

十年热恋 提交于 2021-02-10 14:13:49
问题 I want to remove the NavigationTitle Space without removing the back button. I have already tried this: .navigationBarItems(trailing: NavigationLink(destination: Preferences(viewModel: viewModel).navigationBarHidden(true)) { Image(systemName: "gear") .font(.title2) } ) but that removes the back button as well. 回答1: Standard Back button cannot be shown without navigation bar, because it is navigation item, so part of navigation bar. I assume you just need transparent navigation bar. Here is

Remove space NavigationTitle but not the back button

微笑、不失礼 提交于 2021-02-10 14:11:14
问题 I want to remove the NavigationTitle Space without removing the back button. I have already tried this: .navigationBarItems(trailing: NavigationLink(destination: Preferences(viewModel: viewModel).navigationBarHidden(true)) { Image(systemName: "gear") .font(.title2) } ) but that removes the back button as well. 回答1: Standard Back button cannot be shown without navigation bar, because it is navigation item, so part of navigation bar. I assume you just need transparent navigation bar. Here is

Remove space NavigationTitle but not the back button

痴心易碎 提交于 2021-02-10 14:09:21
问题 I want to remove the NavigationTitle Space without removing the back button. I have already tried this: .navigationBarItems(trailing: NavigationLink(destination: Preferences(viewModel: viewModel).navigationBarHidden(true)) { Image(systemName: "gear") .font(.title2) } ) but that removes the back button as well. 回答1: Standard Back button cannot be shown without navigation bar, because it is navigation item, so part of navigation bar. I assume you just need transparent navigation bar. Here is

Hiding Navigation Bar in case of multiple Navigation Views in SwiftUI

前提是你 提交于 2021-02-10 07:09:46
问题 I am having trouble hiding the navigation bar in case of multiple navigation views. I want navigation bars to be present on first and second screen but not on the third one. struct FirstView: View { init() { UINavigationBar.appearance().backgroundColor = UIColor.green } var body: some View { NavigationView { NavigationLink(destination: SecondView()) { Text("Second View") }.navigationBarTitle("First View") } } } // Second View struct SecondView: View { var body: some View { NavigationLink