Post

Replies

Boosts

Views

Activity

Reply to iOS 26.1 and tabViewBottomAccessory
Okay, so in the meantime you could use something like this: public struct Conditional<Content> { public let content: Content public init(_ content: Content) { self.content = content } } extension View { var conditional: Conditional<Self> { Conditional(self) } } @ViewBuilder func showAccessory(_ enabled: Bool, accessoryContent: View) -> some View { if(enabled) { if #available(iOS 26.2, *) { content .tabViewBottomAccessory(isEnabled: enabled) { accessoryContent } } else { if #available(iOS 26.0, *) { content .tabViewBottomAccessory() { accessoryContent } } else { content } } } else { content } } // Use it like this: ... MyView { } .conditional.showAccessory(true /*or false*/, accessoryContent: MyAccessoryView()) Caveat: I have not tried this.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’25
Reply to iOS 26.1 and tabViewBottomAccessory
From this thread: You'll want to use the new api tabViewBottomAccessory(isEnabled:content:), which allows you dynamically show and hide the view instead of an EmptyView. When isEnabled is true, the accessory view is shown, and when isEnabled is false, the view is hidden. Does that help?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’25
Reply to Get Out of Squircle Jail Free With InstallAware MP
These forums are not for advertising - as you have already been told. Please stop posting about your app on these forums. These forums are for developers to ask for hints and tips on coding, not for advertising apps. I have once again reported your post. No doubt you'll come back with some pointless response again, but you're in the wrong here, as you were last time.
Nov ’25
Reply to PAYMENT
Payment for what? If you want to pay for the Apple Developer Program, it should be in the "Account" section at the top of the page on these forums. And, why have you tagged your post with "Widgets & Live Activities"? Is this related to widgets and Live Activities or not? If not, please don't use unrelated tags on your posts.
Nov ’25
Reply to SwiftUI state is maddening
It just says ItemListView: _dismiss changed. in the console. I've put the code here: https://github.com/darkpawuk/DismissFail Just create a new iOS project in Xcode, remove the standard ContentView.swift and App.swft files, and drop these ones in. Runs on iOS 17 and above (because it uses @Observable).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to SwiftUI state is maddening
Oh, would you look at that? It's nothing at all to do with my variables. It's SwiftUI and these damned Environment variables. This time it was @Environment(\.dismiss) on the view that contains the List, not the rows inside the List. This is what is supposed to happen: The user taps a button in MainView. ItemsListView opens, which contains the List. The user does something in ListItemsView, such as deleting an Item. In order to close ItemsListView the user taps a button in that view, which merely calls dismiss(). dismiss() was used to avoid using a @State var in MainView and a corresponding @Binding var in ItemsListView. This should work, right? Wrong. What actually happens is this: The user taps a button in MainView. ItemsListView opens, which contains the List. The user swipes an ItemRow, then taps the delete button. The confirmation dialog appears, and is attached to the specific row. _dismiss is changed - for some reason - in ItemsListView, which causes the view to redraw, causing the List to redraw, causing every ItemRow to redraw, causing the confirmation dialog to disappear because the row it was attached to no longer exists. Obviously, the fix here is to revert to using @State and @Binding vars, and that does indeed work. So the question becomes: Why on Earth did dismiss change in ItemsListView? Your guess is as good as mine. 7 hours wasted.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to SwiftUI state is maddening
In MainApp I've tried creating the modelData variable with: // These two require ModelData to conform to ObservableObject, and vars must be marked with @Published: @StateObject private var modelData: ModelData = dataService.modelData @ObservedObject private var modelData: ModelData = dataService.modelData // This one uses @Observable instead, and vars aren't explicitly marked as @Published: @State private var modelData: ModelData = dataService.modelData // This is a simple let var: let modelData: ModelData = dataService.modelData In all four cases the entire list refreshes every time I swipe a row and press a button. In the case of the delete button, the confirmation dialog appears then disappears because the row changes. ObservableObject is the 'old' way of doing this, right? ModelData instead has the @Observable annotation. As stated earlier, the DataService is a singleton: DataService.swift: final class DataService { static let shared = DataService() private init() {} let coreData: CoreData = CoreData() let modelData: ModelData = ModelData() } Do I make the creation of the modelData variable here a @State variable instead of in MainApp? I'm really at a loss here. Nothing I try makes any difference. If Apple are listening, you really need to make this stuff easier to figure out and fix. Other IDEs will proactively warn you about code issues, but Xcode just lets you do anything, and doesn't help. The compiler can't even tell you where an error is in a thousand lines of code when you've typed a comma instead of a period. It's frustrating.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to SwiftUI state is maddening
This isn't even fine-tuning, this is just trying to get the entire List to stop being redrawn when something minor happens, end even when nothing has changed! Accessibility DWC hasn't changed, but SwiftUI thinks it has, and so the List redraws every row. I swipe one row and tap the edit button, the List jumps back to the top. No reason at all for that. Nothing has changed, but SwiftUI decides @self, @identity changed so it redraws every row. How did anything change? I didn't change the .id() of the rows - they use the id of the Item which has not changed. When this @State private var showDeleteConfirmation: Bool = false changes on one row because the user swiped and tapped the delete button, the entire List is redrawn. Why? I fear I'm going to end up with hundreds of stupid little hacks to get things to work, and they'll just fail on the next point release of the OS. And, as I've said on multiple occasions over the past week, across three other posts on this subject, this did not happen until iOS/iPadOS 26.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to How to handle alert when deleting row from List
UPDATE: I believe I've found a fix. The issue was partly that the buttons I want in .swipeActions(edge: .leading) { ... } are in a separate View struct called LeftSwipeButtons, and the ones going into .swipeActions(edge: .trailing) { ... } are in their own struct called RightSwipeButtons. This means passing Binding vars into them so that the ItemRow can use them, and send their value back to the view that's got my List in it, i.e.: struct ItemRow: View { @Binding var x: Bool @Binding var y: Bool var body: some View { ... } .swipeActions(edge: .leading) { LeftSwipeButtons(x: $x, y: $y ... ) } .swipeActions(edge: .trailing) { RightSwipeButtons(x: $x, y: $y ... ) // Has .confirmationDialog inside // But also exhibits the issue if I put .confirmationDialog here } .contextMenu { ContextMenu( ... ) // Has .confirmationDialog inside // But also exhibits the issue if I put .confirmationDialog here } } Adding .confirmationDialog inside RightSwipeButtons or inside .swipeActions didn't work because the button disappeared. It seems that the fix for this was to move all that code back into the ItemRow itself and add .confirmationDialog onto the end. Same problem with the context menu. I couldn't add .confirmationDialog inside my ContextMenu struct, or add it inside .contextMenu. Once I moved all the code back into ItemRow it all worked (though ItemRow is now about 450 lines...). struct ItemRow: View { var body: some View { ... } .swipeActions(edge: .leading) { if(a == 1) { ... }. // etc. } .swipeActions(edge: .trailing) { if(b == 2) { ... }. // etc. } .contextMenu { ... } .confirmationDialog { ... } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to How to handle alert when deleting row from List
Okay, I've created new vars in the model data. The initial set of data is read from Core Data, which is then filtered into the standardItems var, and the archived ones go into archivedItems. The List now doesn't use .filter, it just uses the specific set of data as required. However, this did not fix the issue with the list refreshing when I tap the delete swipe button. I want to show an alert to ask for confirmation to delete an item before deleting it. I swipe the row to show the delete button. The moment I tap it, the list refreshes. This happens just because the @State var showAlert has been changed. The confirmation alert does appear, but the list is now at the top (again). Look at the code I added in the first post above. RightSwipeButtons has showAlert as a Binding var, which is why it changes in ItemListView. I can't use confirmationDialog(_:isPresented:titleVisibility:actions:message:) on the swipe button because the button disappears and the alert has nothing to anchor itself to. So, how do I do this? How does anyone do this? It seems every time I make a change to adhere to best practice, SwiftUI throws another obstacle in my way that takes a day or more to figure out - and a lot of refactoring.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to List jumps back to the top
I've spent the last three hours changing every instance of colorScheme == .dark ? Color1 : Color2 into asset colours, and this fixes the Dark Mode issue. All it seems you can do with @Environment(\.colorScheme) var colorScheme is read its value, but not do anything with it for fear it will redraw the entire view. And, when you use it in a view that's used in a List, your entire list will be redrawn. Anyway, that's fixed now. Thanks for your help.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25