When running app on iPhone Xs simulator all works & looks great. When running on SAME Device, the NavigationLinks are being displayed? Issue is NOT present on IPad Device however (i.e., all looks & works fine)?
Issue submitted to Apple with no response as of this writing.
PLATFORM AND VERSION iOS macOS Monterey 12.0.1 XCODE 13.1 BOTH devices (iPhone & iPad) are operating with iOS 15.1 Screenshots & code are below.
STEPS TO REPRODUCE Confirmed NavigationLinks (2 of them) were being displayed on Device by commenting out & they do not show, but of course there is no real link then.
Also tried embedding in VStack & HStack & they BOTH appeared in their respective configurations (i.e., On top of each other in VStack and side-by-side with HStack).
import SwiftUI
import Combine
struct PrimaryView: View {
@EnvironmentObject var gameView: GameViewController
@State private var selection: String? = nil
@State private var showSettingsAlert = false
@State private var showInfoAlert = false
init() {
UINavigationBar.appearance().backgroundColor = .clear
UISegmentedControl.appearance().selectedSegmentTintColor = .blue
UISegmentedControl.appearance().setTitleTextAttributes([.foregroundColor: UIColor.white], for: .selected)
UISegmentedControl.appearance().setTitleTextAttributes([.foregroundColor: UIColor.blue], for: .normal)
}
var body: some View {
NavigationView {
VStack{
GameUIView()
NavigationLink(destination: SettingsView(), tag: "Settings", selection: $selection) { EmptyView() }
NavigationLink(destination: AppInfoView(), tag: "Info", selection: $selection) { EmptyView() }
HStack{
Button( action: {
self.selection = "Settings"
if gameView.gameStarted && !gameView.gamePaused {
self.showSettingsAlert = true
}
}) {
Text("Game Settings")
Image(systemName: (showSettingsAlert ? "gearshape.fill" : "gearshape"))
}
.alert(isPresented: $showSettingsAlert) {
Alert(title: Text("Cannot View or Change Settings!"), message: Text("Game is Running or Game is NOT Paused!! Must not be running or else in Pause State to view Game Settings!"), dismissButton: .default(Text("Got it!")))
}
Spacer()
Button( action: {
self.selection = "Info"
if gameView.gameStarted && !gameView.gamePaused {
self.showInfoAlert = true
}
}) {
Text("Game Info")
Image(systemName: (showInfoAlert ? "questionmark.diamond.fill" : "questionmark.diamond"))
}
.alert(isPresented: $showInfoAlert) {
Alert(title: Text("Cannot View Application Info!"), message: Text("Game is Running or Game is NOT Paused!! Must not be running or else in Pause State to view Game Information!"), dismissButton: .default(Text("Got it!")))
}
.navigationBarHidden(true)
.navigationBarTitle("Back To Game", displayMode: .inline)
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
.alert(isPresented: $gameView.gameEnded, content: {
Alert(title: Text("Game Has Ended"), message: Text("To play game again you MUST close app and restart!"), dismissButton: .default(Text("Got it!")))
})
}
}