Post

Replies

Boosts

Views

Activity

Reply to iOS 26: Navigation bar unexpectedly switches to Light appearance during navigation in Dark Mode
Thank you for your reply. I see you filed a bug, you have provided some code in the bug, thanks for that, but may I ask to upload a focused project showing the issue? I’ve already attached code that reproduces the issue in the first post of this thread. Please note that the issue only occurs on iOS 26 when the device is set to Dark Mode and Reduce Transparency is enabled. I have also uploaded the Xcode project for this sample code to GitHub: https://github.com/hmuronaka/iOS26NavigationTitleSample If so, please share a link to your test project or better upload it into the FB issue I’ve also uploaded the link to the project in the FB report (FB20370553) as well. Thank you for your support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to .highPriorityGesture Prevents Button Tap on iOS 17 and Earlier
Thank you for the reply. Our product previously used simultaneousGesture(_:including:). Recently, I discovered highPriorityGesture and tried using it. It works as expected on iOS 18, but on iOS 17.5 and earlier, the Button tap does not respond, which is why I posted this question. Although there is a difference in behavior between iOS 18 and earlier versions, I would like to use highPriorityGesture to implement our feature specifically for iOS 18.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
This issue still occurs in iOS 18.0 (22A5316j), Xcode 16.0 beta4(16A5211f). I have confirmed that the problem persists even when using @Observable with Observation. The result changes only depending on whether @Environment is defined in the lower-level View. When tapping through the cells to display the DetailView, the screen automatically pops back to the WordBookView. If I comment out @Environment(Env.self) in the WordBookView, the automatic pop does not occur. This issue occurs only on iOS 18.0 beta. It does not occur in iOS 17.5 or earlier. import SwiftUI import Observation @Observable class Env { } struct Book: Identifiable, Sendable, Hashable { let id: UUID = UUID() let name: String var words: [Word] = [] init(name: String) { self.name = name } } struct Word: Identifiable, Sendable, Hashable { let id: UUID = UUID() var word: String init(word: String) { self.word = word } } let staticBooks: [Book] = { (1...10).enumerated().map { var b = Book(name: "Book-\($0)") b.words = (1...100).enumerated().map { return Word(word: "\(b.name)-Word-\($0)") } return b } }() @main struct iOS18NavigaationStackSampleApp: App { var body: some Scene { WindowGroup { NavigationStack() { ContentView() } } } } struct ContentView: View { @State private var env = Env() var body: some View { WordListView() .environment(env) } } struct WordListView: View { @Environment(Env.self) private var env @State var books:[Book] = staticBooks @State var selected: Book? var body: some View { List(selection: $selected) { ForEach(books) { book in NavigationLink(value: book) { Text(book.name) } } } .navigationDestination(item: $selected) { book in WordBookView(book: book) .environment(env) } } } struct WordBookView: View { @Environment(Env.self) var env let book: Book @State var selected: Word? var body: some View { List(selection: $selected) { ForEach(book.words) { word in NavigationLink(value: word) { Text(word.word) } } } .navigationDestination(item: $selected) { word in DetailView(word: word) } } } struct DetailView: View { let word: Word var body: some View { Text(word.word) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’24
Reply to iOS18 beta2 NavigationStack: Tapping Back from a lower-level View returns to the Root View / No transition animation
Thank you for the detailed explanation. I have a question. This example shows undefined behavior. How can SwiftUI developers know that this behavior is undefined? I couldn't find it in the NavigationLink documentation. And thank you for the code rewrite. The sample code worked as expected. In our production code, I will avoid mixing value-destination and view-destination and will use value-destination exclusively. I also understood that using get-set binding for navigationDestination(isPresented:) can cause animation issues. To add, I am using this method to support iOS versions prior to iOS16, where navigationDestination(item:destination) is not available, and it works for versions before iOS18. However, after slightly modifying the rewritten code to match our production code, I encountered a pop issue again. Specifically, when I changed .navigationDestination(for:) to .navigationDestination(item:) within RootView, it automatically pops during the first transition from ContentView to SubView. This issue occurs when using value-destination. In any case, the issue in this article has been resolved, so I will continue the discussion in the other post: iOS18 beta2: NavigationStack, Views Being Popped Automatically.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’24
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
Thank you for the explanation at [https://developer.apple.com/forums/thread/758371]. As you understand, I am using navigationDestination(isPresented ) with get/set binding because navigationDestination(item:) is only supported from iOS 17 onwards. Our product code supports iOS 16 and later. (The product itself also supports iOS 15, so we are using NavigationView as well.) Additionally, when I modified the code provided in the post to be closer to our product code by changing navigationDestination(for:) to navigationDestination(item:), the pop issue reoccurred (during the transition from contentView to subView). Therefore, I believe this issue is not related to the view-destination or value-destination problem. As a workaround, I have confirmed that commenting out @Environment(.dismiss) defined in ContentView avoids the issue. While the code in this article is very simple, our product code is enormous and has a very complex structure, making it extremely difficult to pinpoint the cause when behavior changes with or without @Environment. The following code is automatically popped when navigating from ContentView to SubView on iOS 18 beta 2, but this does not happen on iOS 17.5. import SwiftUI struct Selection: Hashable, Identifiable { var num: Int var id: Int { num } } enum Kind: Hashable { case a case b } struct RootView3: View { @State var kind: Kind? = nil @State var vals: [Selection] = (1...5).map(Selection.init(num:)) @State var selection: Selection? var body: some View { if #available(iOS 17.0, *) { NavigationStack { List(selection: $kind) { NavigationLink("Album-a", value: Kind.a) NavigationLink("Album-b", value: Kind.b) } .navigationDestination(item: $kind, destination: { kind in ContentView3(vals: $vals, selection: $selection) }) // .navigationDestination(for: Kind.self) { kind in // ContentView3(vals: $vals, selection: $selection) // } } } } } @available(iOS 17.0, *) struct ContentView3: View { @Binding var vals: [Selection] @Binding var selection: Selection? @Environment(\.dismiss) private var dismiss var body: some View { List(selection: $selection) { ForEach(self.vals) { val in NavigationLink(value: val) { Text("\(String(describing: val))") } } } .navigationDestination(item: $selection) { sel in SubView3(kind: .a, selection: sel) } } } struct SubView3: View { let kind: Kind let selection: Selection var body: some View { Text("Content. \(kind): \(selection)") } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’24
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
Thank you for your response. I tried the suggested solution, and although it resolved the issue of the view being popped automatically, a different problem has now arisen. (The new issue: Tapping Back from a lower-level View returns to the Root View / No transition animation ) However, while this fix may work for the simplest code, I think it cannot be applied to our production code for the following three reasons: This fix requires placing navigationDestination directly under NavigationStack. In our production code, we have multiple levels such as two, three, or more, each handling different data models within a large navigation view. It's not practical to describe all levels of navigationDestination directly under NavigationStack. This fix introduces another problem, making it unsuitable for inclusion in our production code at this time. I am unsure whether this behavior is due to a specification change in iOS 18 or a bug in the iOS 18 beta, and whether this solution is just a temporary workaround. Regardless, thank you for your advice. I hope the behavior of NavigationStack and SwiftUI stabilizes soon.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Reply to iOS 26: Navigation bar unexpectedly switches to Light appearance during navigation in Dark Mode
Thank you for your reply. I see you filed a bug, you have provided some code in the bug, thanks for that, but may I ask to upload a focused project showing the issue? I’ve already attached code that reproduces the issue in the first post of this thread. Please note that the issue only occurs on iOS 26 when the device is set to Dark Mode and Reduce Transparency is enabled. I have also uploaded the Xcode project for this sample code to GitHub: https://github.com/hmuronaka/iOS26NavigationTitleSample If so, please share a link to your test project or better upload it into the FB issue I’ve also uploaded the link to the project in the FB report (FB20370553) as well. Thank you for your support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’25
Reply to iOS 26: Navigation bar unexpectedly switches to Light appearance during navigation in Dark Mode
I was able to reproduce this on the iOS Simulator by enabling Reduce Transparency. In addition, this behavior occurs not only in the sample project but also in iOS 26 system apps such as Files and others, so I believe it is an iOS 26 issue. iOS 26 File app
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’25
Reply to iOS 26: Navigation bar unexpectedly switches to Light appearance during navigation in Dark Mode
I have posted FB20370553.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’25
Reply to StateObject is not deinitialized when List(selection:) binding
I've posted FB18710603
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’25
Reply to .highPriorityGesture Prevents Button Tap on iOS 17 and Earlier
The behavior on iOS 18 seems appropriate, however if you'd like engineering to investigate the issue, you could open a bug report, include a test project and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report. I have posted FB17598905
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to .highPriorityGesture Prevents Button Tap on iOS 17 and Earlier
Thank you for the reply. Our product previously used simultaneousGesture(_:including:). Recently, I discovered highPriorityGesture and tried using it. It works as expected on iOS 18, but on iOS 17.5 and earlier, the Button tap does not respond, which is why I posted this question. Although there is a difference in behavior between iOS 18 and earlier versions, I would like to use highPriorityGesture to implement our feature specifically for iOS 18.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to List Layout Breaks in NavigationStack When a View Exceeds Screen Width
As an additional note, in my environment, turning on the Accessibility setting [Button Shapes] causes the content to exceed the width and break the view layout, so I’m looking for a way to detect whether [Button Shapes] is enabled.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’25
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
Regarding FB14055676, I received a message from Apple indicating that this issue has been fixed in iOS 18 Beta 6. As far as I have tested with the sample code and our production code, it appears that the issue has been resolved. Thank you for fixing this issue.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
This issue still occurs in iOS 18.0 (22A5316j), Xcode 16.0 beta4(16A5211f). I have confirmed that the problem persists even when using @Observable with Observation. The result changes only depending on whether @Environment is defined in the lower-level View. When tapping through the cells to display the DetailView, the screen automatically pops back to the WordBookView. If I comment out @Environment(Env.self) in the WordBookView, the automatic pop does not occur. This issue occurs only on iOS 18.0 beta. It does not occur in iOS 17.5 or earlier. import SwiftUI import Observation @Observable class Env { } struct Book: Identifiable, Sendable, Hashable { let id: UUID = UUID() let name: String var words: [Word] = [] init(name: String) { self.name = name } } struct Word: Identifiable, Sendable, Hashable { let id: UUID = UUID() var word: String init(word: String) { self.word = word } } let staticBooks: [Book] = { (1...10).enumerated().map { var b = Book(name: "Book-\($0)") b.words = (1...100).enumerated().map { return Word(word: "\(b.name)-Word-\($0)") } return b } }() @main struct iOS18NavigaationStackSampleApp: App { var body: some Scene { WindowGroup { NavigationStack() { ContentView() } } } } struct ContentView: View { @State private var env = Env() var body: some View { WordListView() .environment(env) } } struct WordListView: View { @Environment(Env.self) private var env @State var books:[Book] = staticBooks @State var selected: Book? var body: some View { List(selection: $selected) { ForEach(books) { book in NavigationLink(value: book) { Text(book.name) } } } .navigationDestination(item: $selected) { book in WordBookView(book: book) .environment(env) } } } struct WordBookView: View { @Environment(Env.self) var env let book: Book @State var selected: Word? var body: some View { List(selection: $selected) { ForEach(book.words) { word in NavigationLink(value: word) { Text(word.word) } } } .navigationDestination(item: $selected) { word in DetailView(word: word) } } } struct DetailView: View { let word: Word var body: some View { Text(word.word) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to Is ObservableObject implicitly a MainActor in iOS 16 and later?
I forgot to include the environment details: Xcode: Version 16.0 beta 3 (16A5202i) Swift: Swift 6 Strict Concurrency Checking: Complete
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to iOS18 beta2 NavigationStack: Tapping Back from a lower-level View returns to the Root View / No transition animation
Thank you for the detailed explanation. I have a question. This example shows undefined behavior. How can SwiftUI developers know that this behavior is undefined? I couldn't find it in the NavigationLink documentation. And thank you for the code rewrite. The sample code worked as expected. In our production code, I will avoid mixing value-destination and view-destination and will use value-destination exclusively. I also understood that using get-set binding for navigationDestination(isPresented:) can cause animation issues. To add, I am using this method to support iOS versions prior to iOS16, where navigationDestination(item:destination) is not available, and it works for versions before iOS18. However, after slightly modifying the rewritten code to match our production code, I encountered a pop issue again. Specifically, when I changed .navigationDestination(for:) to .navigationDestination(item:) within RootView, it automatically pops during the first transition from ContentView to SubView. This issue occurs when using value-destination. In any case, the issue in this article has been resolved, so I will continue the discussion in the other post: iOS18 beta2: NavigationStack, Views Being Popped Automatically.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
Thank you for the explanation at [https://developer.apple.com/forums/thread/758371]. As you understand, I am using navigationDestination(isPresented ) with get/set binding because navigationDestination(item:) is only supported from iOS 17 onwards. Our product code supports iOS 16 and later. (The product itself also supports iOS 15, so we are using NavigationView as well.) Additionally, when I modified the code provided in the post to be closer to our product code by changing navigationDestination(for:) to navigationDestination(item:), the pop issue reoccurred (during the transition from contentView to subView). Therefore, I believe this issue is not related to the view-destination or value-destination problem. As a workaround, I have confirmed that commenting out @Environment(.dismiss) defined in ContentView avoids the issue. While the code in this article is very simple, our product code is enormous and has a very complex structure, making it extremely difficult to pinpoint the cause when behavior changes with or without @Environment. The following code is automatically popped when navigating from ContentView to SubView on iOS 18 beta 2, but this does not happen on iOS 17.5. import SwiftUI struct Selection: Hashable, Identifiable { var num: Int var id: Int { num } } enum Kind: Hashable { case a case b } struct RootView3: View { @State var kind: Kind? = nil @State var vals: [Selection] = (1...5).map(Selection.init(num:)) @State var selection: Selection? var body: some View { if #available(iOS 17.0, *) { NavigationStack { List(selection: $kind) { NavigationLink("Album-a", value: Kind.a) NavigationLink("Album-b", value: Kind.b) } .navigationDestination(item: $kind, destination: { kind in ContentView3(vals: $vals, selection: $selection) }) // .navigationDestination(for: Kind.self) { kind in // ContentView3(vals: $vals, selection: $selection) // } } } } } @available(iOS 17.0, *) struct ContentView3: View { @Binding var vals: [Selection] @Binding var selection: Selection? @Environment(\.dismiss) private var dismiss var body: some View { List(selection: $selection) { ForEach(self.vals) { val in NavigationLink(value: val) { Text("\(String(describing: val))") } } } .navigationDestination(item: $selection) { sel in SubView3(kind: .a, selection: sel) } } } struct SubView3: View { let kind: Kind let selection: Selection var body: some View { Text("Content. \(kind): \(selection)") } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to iOS18 beta2 NavigationStack: Tapping Back from a lower-level View returns to the Root View / No transition animation
I have posted FB14125143, and FB11599516 around the time of iOS 16 beta.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to iOS18 beta2: NavigationStack, Views Being Popped Automatically
Thank you for your response. I tried the suggested solution, and although it resolved the issue of the view being popped automatically, a different problem has now arisen. (The new issue: Tapping Back from a lower-level View returns to the Root View / No transition animation ) However, while this fix may work for the simplest code, I think it cannot be applied to our production code for the following three reasons: This fix requires placing navigationDestination directly under NavigationStack. In our production code, we have multiple levels such as two, three, or more, each handling different data models within a large navigation view. It's not practical to describe all levels of navigationDestination directly under NavigationStack. This fix introduces another problem, making it unsuitable for inclusion in our production code at this time. I am unsure whether this behavior is due to a specification change in iOS 18 or a bug in the iOS 18 beta, and whether this solution is just a temporary workaround. Regardless, thank you for your advice. I hope the behavior of NavigationStack and SwiftUI stabilizes soon.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24
Reply to iOS18 beta2 NavigationStack: Tapping Back from a lower-level View returns to the Root View / No transition animation
This problem may not be a regression but rather an issue that has not been fixed since iOS16.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24