I am using SwiftUI NavigationView to navigate. I cant find how can i disable swipe from the leftmost part of the screen for navigation bar. In tried this way , but it doesn't work for me:
struct DisableSwipeBackGesture: ViewModifier {
func body(content: Content) -> some View {
content
.background(DisableBackSwipeGestureView())
}
}
struct DisableBackSwipeGestureView: UIViewControllerRepresentable {
typealias UIViewControllerType = DisableSwipeBackViewController
func makeUIViewController(context: Context) -> DisableSwipeBackViewController {
DisableSwipeBackViewController()
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
func makeCoordinator() -> Coordinator {
return Coordinator()
}
class Coordinator: NSObject, UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
}
final class DisableSwipeBackViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let navigationController = self.navigationController {
if let interactivePopGestureRecognizer = navigationController.interactivePopGestureRecognizer {
interactivePopGestureRecognizer.delegate = self
interactivePopGestureRecognizer.isEnabled = false
}
}
}
}
extension DisableSwipeBackViewController: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
extension View {
func disableSwipeBackGesture() -> some View {
self.modifier(DisableSwipeBackGesture())
}
}
Is there a way to disable this feature?
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Post
Replies
Boosts
Views
Activity
I am using SwiftUI NavigationView to navigate. I cant find how can i disable swipe from the leftmost part of the screen for navigation bar. Im tried this way , but it doesn't work for me:
struct DisableBackSwipeGestureView: UIViewControllerRepresentable {
typealias UIViewControllerType = UINavigationController
func makeUIViewController(context: Context) -> UINavigationController {
DisableSwipeBackViewController().navigationController ?? UINavigationController()
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
func makeCoordinator() -> Coordinator {
return Coordinator()
}
class Coordinator: NSObject, UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
}
final class DisableSwipeBackViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let navigationController = self.navigationController {
if let interactivePopGestureRecognizer = navigationController.interactivePopGestureRecognizer {
interactivePopGestureRecognizer.delegate = self
interactivePopGestureRecognizer.isEnabled = false
}
}
}
}
extension DisableSwipeBackViewController: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return false
}
}
extension View {
func disableSwipeBackGesture() -> some View {
self.modifier(DisableSwipeBackGesture())
}
}
Is there a way to disable this feature in swiftui?
Hello everyone, I am using the new AccessorySetupKit, and whenever I try to remove an accessory I sometimes get an alert asking me to make sure if I want to remove the accessory from my device. The problem is that this alert sometimes shows up, and sometimes it does not. The removal of the accessory does work, it is just that the alert is not predictable. Is this expected behavior? How can we “predict” when it will show up and when it will not?
I'm adding support for Genmoji to my app but it's unclear to me if this is something that should be called manually in code to insert an adaptive image glyph or if this is something that the system calls when the user inserts a Genmoji / adaptive image glyph object (ie. sticker) into the UITextView.
With the upcoming launch of Apple Intelligence and Writing Tools, we've been forced to migrate our text editing app to TextKit 2. As soon as we released the update, we immediately got complaints about incorrect selection behaviour, where the user would tap a word to begin editing, but the caret would be shown in an undefined location, often dozens of paragraphs below the selected content.
To reproduce:
Create a UITextView backed by a standard TextKit 2 stack and a large amount of text (50,000+ words) - see sample project below
Scroll quickly through the text view (at least 20% of the way down)
Tap once to select a position in the document.
Expected:
The caret appears at the location the user tapped, and UITextView.selectedRange is the range of the text at the location of the tap. This is the behaviour of TextKit 1 based UITextViews.
Actual:
The caret is positioned at an undefined location (often completely off screen), and the selectedRange is different to the range at the location of the tap, often by several thousand. There is no pattern to the magnitude of the discrepancy.
This incorrect behaviour occurs consistently in the sample project on the simulator, but you may need to hide the keyboard by pulling down, then repeat steps 2-3 a few times. This happens on iPhone and iPad, and on iOS 17, 18, and 18.1.
Do you have any insight into why this might be happening or how to work around this issue?
Sample code is here: https://github.com/nathantesler/textkit2-issue/tree/master
UITextView changed the sequence of views and on the top UIView. As a result in the custom gesture class in "touchesBegan" method, this code brings me "let touchedView = touches.first?.view" type of view UIView but it must be my own custom class type.
How can I get a tapped type of view? Help please
override func touchesBegan(_ touches: Set, with event: UIEvent) {
super.touchesBegan(touches, with: event)
let touchedView = touches.first?.view
}
Hello,
I'm encountering an issue with toolbarColorScheme in iOS 18. In a simple example, toolbarColorScheme works fine when triggered in onAppear. However, after navigating to a different view (e.g., following a link, such as link 234), and then returning, the toolbarColorScheme seems to be ignored.
Could anyone help me resolve this issue?
struct TestNavigationBarColor: View {
var body: some View {
NavigationStack {
List {
Text("123")
NavigationLink(value: 1) {
Text("234")
}
}
.toolbarColorScheme(.dark, for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Title1")
.navigationDestination(for: Int.self) {_ in
List {
Text("Nested screen")
}
.navigationTitle("Title2")
}
}
}
}
Hello,
In our current project we are using NavigationSplitView in the following way:
var body: some View {
NavigationSplitView(
sidebar: {
ListView()
},
detail: {
DetailsView()
}
)
.navigationBarHidden(true)
.navigationSplitViewStyle(.automatic)
.introspectSplitViewController { splitViewController in
splitViewController.preferredDisplayMode = .oneOverSecondary
splitViewController.maximumPrimaryColumnWidth = 500
splitViewController.preferredPrimaryColumnWidthFraction = 1
}
}
}
And in iPhone the DetailsView() is pushed using the navigationDestination modifier:
.navigationDestination(isPresented: $isShowingDetailsScreen) {
DetailsView()
.navigationBarHidden(true)
}
where isShowingDetailsScreen is updated through a button click:
Button() {
self.isShowingDetailsScreen = true
}
This works perfectly in iOS versions prior to 18. However starting from this version the button click no longer presents the view desired. Below is what happening in the latest iOS versions:
iOS 18: This mechanism is broken altogether, it does not work at all.
iOS 18.1: This mechanism is partially broken, when clicking on the button the DetailsView is not presented, however since the page also contains other reactive views, any time one of them is changed through a state change after clicking on that button, the DetailsView is presented.
Does anyone faced an issue like this with the new iOS and if so is there any workaround for now? Because this seems to be a bug caused by changes in SwiftUI and shouldn't persist for long.
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Reason: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process:XXXX [XXXX]
Triggered by Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
UserInfo:(null)'
Last Exception Backtrace:
0 CoreFoundation 0x1930d108c __exceptionPreprocess + 164 (NSException.m:249)
1 libobjc.A.dylib 0x1903d32e4 objc_exception_throw + 88 (objc-exception.mm:356)
2 CoreFoundation 0x193070424 -[__NSArrayM insertObject:atIndex:] + 1276 (NSArrayM.m:164)
3 UIKitCore 0x195b6249c 0x195818000 + 3450012
4 UIKitCore 0x1958c9070 0x195818000 + 725104
5 UIKitCore 0x195899c3c _UIGestureEnvironmentUpdate + 2488 (UIGestureEnvironment.m:192)
6 UIKitCore 0x19598f914 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 336 (UIGestureEnvironment.m:843)
7 UIKitCore 0x195b2ff18 -[UIGestureEnvironment _updateForEvent:window:] + 188 (UIGestureEnvironment.m:810)
8 UIKitCore 0x195b2f2fc -[UIWindow sendEvent:] + 2948 (UIWindow.m:3627)
11 UIKitCore 0x1959c39b4 -[UIApplication sendEvent:] + 376 (UIApplication.m:12948)
13 UIKitCore 0x1959c3ee0 __dispatchPreprocessedEventFromEventQueue + 1048 (UIEventDispatcher.m:2641)
14 UIKitCore 0x1959cdcc4 __processEventQueue + 5696 (UIEventDispatcher.m:2999)
15 UIKitCore 0x1958c6270 updateCycleEntry + 160 (UIEventDispatcher.m:133)
16 UIKitCore 0x1958c3fe8 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:136)
17 UIKitCore 0x1958c3c38 schedulerStepScheduledMainSection + 172 (_UIUpdateScheduler.m:1171)
18 UIKitCore 0x1958c4bac runloopSourceCallback + 92 (_UIUpdateScheduler.m:1334)
19 CoreFoundation 0x1930a4088 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 (CFRunLoop.c:1950)
20 CoreFoundation 0x1930a401c __CFRunLoopDoSource0 + 176 (CFRunLoop.c:1994)
21 CoreFoundation 0x1930a1b08 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2031)
22 CoreFoundation 0x1930a0d04 __CFRunLoopRun + 840 (CFRunLoop.c:2949)
23 CoreFoundation 0x1930a05b8 CFRunLoopRunSpecific + 572 (CFRunLoop.c:3414)
24 GraphicsServices 0x1deb361c4 GSEventRunModal + 164 (GSEvent.c:2196)
25 UIKitCore 0x195bf65f0 -[UIApplication _run] + 816 (UIApplication.m:3820)
26 UIKitCore 0x195ca510c UIApplicationMain + 340 (UIApplication.m:5472)
27 XXXX 0x104744880 main + 200 (main.m:41)
28 dyld 0x1b8873d34 start + 2724 (dyldMain.cpp:1334)
I was creating a sample SwiftData project using two models and a one to one relationship. Before upgrading to xcode 16, everything was fine and compiled correctly. After upgrading to xcode 16, I get fatal errors: "This model instance was destroyed by calling ModelContext.reset and is no longer usable" or
I have a button on a live activity, and I want to end the live activity and update the Control Center widgets and home screen widgets after clicking this button. So, in the perform() method of the button's LiveActivityIntent, I called the methods ControlCenter.shared.reloadAllControls() and WidgetCenter.shared.reloadAllTimelines(), but they didn't work. Home screen widgets and Control Center widgets do not refresh, resulting in a poor user experience.
When using the new .navigationTransition feature, when using .searchable at the same time result in the search bar disappearing when dismissing the view you've trasition to, has anyone else experienced this or found any workarounds? Here is an example that make the issue always occur.
@State private var searchText: String = ""
@Namespace private var namespace
let things: [String] = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirdteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty"]
var body: some View {
NavigationStack {
ScrollView {
LazyVStack(spacing: 20) {
ForEach(things, id: \.self) { thing in
NavigationLink(){
SwiftUIView(thing: thing, name: namespace)
}label: {
Text(thing)
}
.matchedTransitionSource(id: thing, in: namespace)
}
}
}
.searchable(text: $searchText)
.navigationTitle("My List")
.navigationBarTitleDisplayMode(.inline)
}
}
}
struct SwiftUIView: View {
var thing: String
var name: Namespace.ID
var body: some View {
Text(thing)
.navigationTransition(.zoom(sourceID: thing, in: name))
}
}
After running the code you end up with this:
And after clicking an element and dismissing it your get this:
Hi! I have a stateful object that should be created in my app entry point and delivered through my component graph:
@main
@MainActor struct MyApp : App {
@State private var myAppState = MyAppState()
var body: some Scene {
...
}
}
The MyApp is a struct value type… in a SwiftUI world that seems to imply it could "go away" and be recreated as the system sees appropriate. We see this with view components all the time (hence the State wrapper to help preserve our instance across the lifecycle of our identity)… but I'm wondering if this State wrapper is even necessary with an App entry point. Could this struct ever go away? Would there be any legit reasons that this struct should go away and recreate over one SwiftUI app lifecycle (other than terminating the app and starting a whole new process of course)?
And what lifecycle is the SwiftUI.State tied to in this example? In a view component our SwiftUI.State is tied to our component identity. In this example… we are tied to app component identity? Is there ever going to be multiple legit app component identities live in the same process?
I'm thinking I could just go ahead and keep using State as a best practice… but is this just overkill or is there a real best practice lurking under here? Any more ideas about that? Thanks!
I have been using the QLPreviewController in an app for some time now and have always gotten a flurry of constraint warnings when it launches which I have ignored. I have looked at them and don't believe they are due to my code and the app seems to work.
Tried to attach a simple app that loads a ViewController with a single button that when pressed creates an object that generates and displays a CSV file via QLPreviewController but can't.
First warning:
Invalid content type identifier com.apple.pktransaction specified in extension com.apple.Passbook.QuicklookPreviewExtension
Second warning:
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x60000213ae40 h=-&- v=--& UINavigationBar:0x10621ddf0.minY == 0 (active, names: '|':UILayoutContainerView:0x106208830 )>",
"<NSAutoresizingMaskLayoutConstraint:0x60000213ae90 h=-&- v=--& UINavigationBar:0x10621ddf0.height == 44 (active)>",
"<NSLayoutConstraint:0x600002137890 V:[UINavigationBar:0x10621ddf0]-(0)-[UIFocusContainerGuide:0x600003d04000'UINavigationControllerContentFocusContainerGuide'] (active)>",
"<NSLayoutConstraint:0x600002137020 UIFocusContainerGuide:0x600003d04000'UINavigationControllerContentFocusContainerGuide'.bottom == UILayoutContainerView:0x106208830.bottom (active)>",
"<NSLayoutConstraint:0x6000021366c0 V:|-(0)-[UILayoutContainerView:0x106208830] (active, names: QLPreviewControllerView:0x10631de80, '|':QLPreviewControllerView:0x10631de80 )>",
"<NSLayoutConstraint:0x600002134d20 V:[UILayoutContainerView:0x106208830]-(0)-| (active, names: QLPreviewControllerView:0x10631de80, '|':QLPreviewControllerView:0x10631de80 )>",
"<NSLayoutConstraint:0x60000211dcc0 'UIView-Encapsulated-Layout-Height' QLPreviewControllerView.height == 0 (active, names: QLPreviewControllerView:0x10631de80 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002137890 V:[UINavigationBar:0x10621ddf0]-(0)-[UIFocusContainerGuide:0x600003d04000'UINavigationControllerContentFocusContainerGuide'] (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
dealloc Query controller [A899BAB1-6730-4B7D-9CBE-488EC6641B6B]
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x6000021229e0 h=--& v=--& _UIToolbarContentView:0x10641e920.width == 0 (active)>",
"<NSLayoutConstraint:0x60000213a6c0 H:|-(0)-[_UIButtonBarStackView:0x106507620] (active, names: '|':_UIToolbarContentView:0x10641e920 )>",
"<NSLayoutConstraint:0x60000213a710 H:[_UIButtonBarStackView:0x106507620]-(0)-| (active, names: '|':_UIToolbarContentView:0x10641e920 )>",
"<NSLayoutConstraint:0x600002146bc0 'IB_Leading_Leading' H:|-(16)-[_UIModernBarButton:0x106519cd0] (active, names: '|':_UIButtonBarButton:0x106519ab0 )>",
"<NSLayoutConstraint:0x600002146c60 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106519cd0]-(16)-| (active, names: '|':_UIButtonBarButton:0x106519ab0 )>",
"<NSLayoutConstraint:0x600002147f70 'UISV-canvas-connection' UILayoutGuide:0x600003b050a0'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x106519ab0.leading (active)>",
"<NSLayoutConstraint:0x60000213b020 'UISV-canvas-connection' UILayoutGuide:0x600003b050a0'UIViewLayoutMarginsGuide'.trailing == UIView:0x10651c300.trailing (active)>",
"<NSLayoutConstraint:0x60000213bde0 'UISV-spacing' H:[_UIButtonBarButton:0x106519ab0]-(0)-[UIView:0x10651c300] (active)>",
"<NSLayoutConstraint:0x60000213a5d0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x600003b050a0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x106507620 )>",
"<NSLayoutConstraint:0x60000213a670 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600003b050a0'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x106507620 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002146c60 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106519cd0]-(16)-| (active, names: '|':_UIButtonBarButton:0x106519ab0 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x6000021374d0 UILayoutGuide:0x600003b21340'TitleView(layout=0x106416a30)'.leading >= UILayoutGuide:0x600003b216c0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x6000021372f0 UILayoutGuide:0x600003b21340'TitleView(layout=0x106416a30)'.trailing <= UILayoutGuide:0x600003b216c0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x60000216ce60 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x106416700.width == 0 (active)>",
"<NSLayoutConstraint:0x600002134f50 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600003b216c0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x106416700 )>",
"<NSLayoutConstraint:0x600002134b90 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600003b216c0'UIViewLayoutMarginsGuide']-(16)-|(LTR) (active, names: '|':_UINavigationBarContentView:0x106416700 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000021372f0 UILayoutGuide:0x600003b21340'TitleView(layout=0x106416a30)'.trailing <= UILayoutGuide:0x600003b216c0'UIViewLayoutMarginsGuide'.trailing (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
I'm facing an issue with SwiftUI's NavigationStack when using the searchable modifier. Everything works as expected when navigating between views, but if I use the search bar to filter a list and then tap on a filtered result, I can navigate to the next view. However, in the subsequent view, my "Set and Return to Root" button, which is supposed to call popToRoot(), does not work. Here's the setup:
Structure: RootView: Contains a list with items 1-7. ActivityView: Contains a list of activities that can be filtered with the searchable modifier. SettingView: Contains a button labeled "Set and Return to Root" that calls popToRoot() to navigate back to the root view.
RootView
struct RootView: View {
@EnvironmentObject var navManager: NavigationStateManager
var body: some View {
NavigationStack(path: $navManager.selectionPath) {
List(1...7, id: \.self) { item in
Button("Element \(item)") {
// Navigate to ActivityView with an example string
navManager.selectionPath.append(NavigationTarget.activity)
}
}
.navigationTitle("Root View")
.navigationDestination(for: NavigationTarget.self) { destination in
switch destination {
case .activity:
ActivityView()
case .settings:
SettingsView()
}
}
}
}
}
ActivityView
struct ActivityView: View {
@EnvironmentObject var navManager: NavigationStateManager
let activities = ["Running", "Swimming", "Cycling", "Hiking", "Yoga", "Weightlifting", "Boxing"]
@State private var searchText = ""
var filteredActivities: [String] {
if searchText.isEmpty {
return activities
} else {
return activities.filter { $0.localizedCaseInsensitiveContains(searchText) }
}
}
var body: some View {
List {
ForEach(filteredActivities, id: \.self) { activity in
NavigationLink(
destination: SettingsView(), // Navigiere zur SettingsView
label: {
HStack {
Text(activity)
.padding()
Spacer()
}
}
)
}
}
.navigationTitle("Choose Activity")
.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search Activities")
}
}
SettingView
struct SettingsView: View {
@EnvironmentObject var navManager: NavigationStateManager
var body: some View {
VStack {
Text("Settings")
.font(.largeTitle)
.padding()
Button("Set and Return to Root") {
// Pop to the root view when the button is pressed
navManager.popToRoot()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
.navigationTitle("Settings")
}
}
NavigationStateManager
// Define enum globally at the top
enum NavigationTarget {
case activity
case settings
}
class NavigationStateManager: ObservableObject {
@Published var selectionPath = NavigationPath()
func popToRoot() {
selectionPath = NavigationPath()
}
func popView() {
selectionPath.removeLast()
}
}
Problem
When I search in the ActivityView and tap on a filtered result, I successfully navigate to the SettingView. However, in this view, pressing the "Set and Return to Root" button does not trigger the navigation back to RootView, even though popToRoot() is being called.
This issue only occurs when using the search bar and filtering results. If I navigate without using the search bar, the button works as expected.
Question
Why is the popToRoot() function failing after a search operation, and how can I ensure that I can return to the root view after filtering the list?
Any insights or suggestions would be greatly appreciated!
When there are more than 5 tabs in TabView, the tabs from the 5th and on get put in the "More" tab as a list.
But when each tab has its own NavigationStack, the tabs in "More" would have double navigation bars. The expected behavior is there should be only one navigation bar, and NavigationStack for tabs in "More" should be collapsed with navigation for the "More" tab itself.
Minimal reproducible case:
Run the code below as an app
Navigate to "More" tab
Navigate to "Tab 5" or "Tab 6"
You can see there are two navigation bars stacked on top of each other
struct Item: Identifiable {
let name: String
var id: String { name }
}
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
let items = [
Item(name: "Tab 1"),
Item(name: "Tab 2"),
Item(name: "Tab 3"),
Item(name: "Tab 4"),
Item(name: "Tab 5"),
Item(name: "Tab 6"),
]
var body: some View {
TabView {
ForEach(items) { item in
NavigationStack {
List {
Text(item.name)
}.navigationTitle(item.name)
}.tabItem {
Label(item.name, systemImage: "person")
}
}
}
}
}
Before iOS 18, I can get around this issue by making my own "More" tab. But now with the expectation that user can re-arrange the tabs and all tabs would show up in the sidebar, the "make my own more tab" approach no longer work very well.
Failed to build module 'Charts'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.7.41 clang-1600.0.24.1)', while this compiler is 'Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.9.11 clang-1600.0.26.2)'). Please select a toolchain which matches the SDK.
Any fix yet?
Since iOS 18 I have noticed a strange issue which happens to the TabView in SwiftUI when you switch from Dark to Light mode.
With this code:
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
List {
ForEach(0..<100, id: \.self) { index in
Text("Row: \(index)")
}
}.tabItem {
Image(systemName: "house")
Text("Home")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The TabBar does not switch colours when going from dark to light, it work correctly when going from light to dark.
Here is a video of iOS 18 with the issue:
Here is a video of iOS 17.5 with same code and no issue:
On real device it looks (better), the color does update but with delay.
I have submitted a feedback bug report, but in the meanwhile has anyone been back to resolve this?
Some users have reported that the app's widgets have disappeared after we updated to the latest Xcode for iOS 18 development. They are unable to find our app in the widget search, which prevents them from re-adding the widget. We were unable to reproduce this issue on our own devices during testing. Could this be a system bug? Have others encountered a similar issue?
Apparently, the half-a-sec boxy notification issue remains up until now???
Please help fix the bug, Apple Dev. how come an issue from ios 16 still happening now in ios 18?
reference: https://www.reddit.com/r/ios/s/Qx116rGBzM