Search results for

swiftui

16,633 results found

Post

Replies

Boosts

Views

Activity

SwiftUI Picker layout under MacOS26
Prior to MacOS 26, Multiple Pickers could be laid out with a uniform width. For example: struct LayoutExample: View { let fruits = [apple, banana, orange, kiwi] let veg = [carrot, cauliflower, peas, Floccinaucinihilipilification Cucurbitaceae] @State private var selectedFruit: String = kiwi @State private var selectedVeg: String = carrot var body: some View { VStack(alignment: .leading) { Picker(selection: $selectedFruit) { ForEach(fruits, id: .self, content: Text.init) } label: { Text(Fruity choice) .frame(width: 150, alignment: .trailing) } .frame(width: 300) Picker(selection: $selectedVeg) { ForEach(veg, id: .self, content: Text.init) } label: { Text(Veg) .frame(width: 150, alignment: .trailing) } .frame(width: 300) } } } Renders like this, prior to MacOS26: But now looks like this under MacOS 26: Is there anyway to control the size of the picker selection in MacOS 26?
1
0
84
Sep ’25
Liquid Glass Effects in iOS 26 Simulators vs Real iPhones
We are seeing some unexpected differences in the appearance of our App when run on a real iPhone (iOS 26 final release) compared to iOS 26 simulators in Xcode 26. Our App run in the iOS 26 simulators (for any iPhone model we try) shows more Liquid Glass effects / artifacts than when run on real devices: In Light Mode buttons in the top Navigation Bar have a surrounding bubble on the simulators. (See attached screen shots.) A SwiftUI Picker element shows more elaborate Liquid Glass transition effects. Also: some UI elements are positioned differently on the simulators compared to a real device. (See the search field under the header on the attached screen shots.) The simulators have in the past been very faithful to the real devices. Is there a setting that controls this behaviour? For the simulator I have: macOS 26.0 Xcode Version 26.0 (17A324) Simulator is iPhone 15 / iOS 26.0 (23A343) Real device is: iPhone 16e iOS 26.0 (23A341)
1
0
148
Sep ’25
Reply to How To Position Controls With SwiftUI
Thanks Claude31, for the screenSize info. That will come in very handy. From your red rectangles above, I am starting to understand that one needs to make use of Views, and more specifically, multiple Views, one for each of the red rectangles above. The code below shows how to stack two Views. Notice MyCustomView is embedded inside the first View below. I have looked at many videos on how to stack more Views, but have not come across any examples. Is there any documentation of how to stack multiple Views. import SwiftUI struct ContentView: View { var body: some View { VStack { MyCustomView() Image(systemName: star.fill) .font(.largeTitle) .foregroundColor(.yellow) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Looking for advice on app architecture
Using Instruments, I see that the view seems to recreate the subviews three times per keyboard event, so I'm clearly doing something wrong. Not necessarily Most SwiftUI stuff on the web is iOS-oriented, and typically has a focus on fairly simple apps, so the whole topic of dealing with menu commands doesn't get a lot of coverage Correct What I've been able to find is not particularly helpful for a full-fledged application like mine, so I'm looking for advice on how to structure the app. You don't have to use SwiftUI.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
iOS 26 navigationTransition .zoom issue
When I dismiss a view presented with .navigationTransition(.zoom), the source view gets a weird background (black or white depending on the appearance) for a couple of seconds, and then it disappears. Here’s a simple code example. import SwiftUI struct NavigationTransition: View { @Namespace private var namespace @State private var isSecondViewPresented = false var body: some View { NavigationStack { ZStack { DetailView(namespace: namespace) .onTapGesture { isSecondViewPresented = true } } .fullScreenCover(isPresented: $isSecondViewPresented) { SecondView() .navigationTransition(.zoom(sourceID: world, in: namespace)) } } } } struct DetailView: View { var namespace: Namespace.ID var body: some View { ZStack { Color.blue Text(Hello World!) .foregroundStyle(.white) .matchedTransitionSource(id: world, in: namespace) } .ignoresSafeArea() } } struct SecondView: View { var body: some View { ZStack { Color.green Image(systemName: globe) .foregroundStyle(Color.red) } .ignoresSafeArea() } } #Preview { Navigati
5
0
294
Sep ’25
Reply to PSVR2 controllers don't report anything in snapshot
Have you added the GCEventInteraction view interaction (UIKit), or handlesGameControllerEvents(matching:) modifier (SwiftUI) to the content view in your application? Controller events are not made available through the GameController framework without these modifiers attached to a view. As you observed, the controller events are converted into pinch/scroll events by default.
Topic: Graphics & Games SubTopic: GameKit Tags:
Sep ’25
Bug Report: SwiftUI @State Array Assignment Fails to Trigger UI Updates. Presumably when lengths of the old and new arrays are the same.
Environment: — Xcode Version: [Current version] — iOS Version: [Target iOS version] — Swift Version: 6.0.3 — Platform: iOS Summary: Direct assignment of new arrays to @State properties sometimes fails to trigger UI updates, even when the arrays contain different data. The assignment appears to succeed in code but the UI continues to display stale data. Presumably when lengths of both arrays are the same. Assigning first empty array and then the new array fixed the issue. Expected Behavior: When assigning a new array to a @State property (self.stateArray = newArray), SwiftUI should detect the change and update the UI to reflect the new data. Actual Behavior: The assignment self.stateArray = newArray executes without error, but the UI continues to display data from the previous array. Debugging shows that self._stateArray (the underlying property wrapper) retains the old data despite the assignment. Minimal Reproduction Case: struct ContentView: View { @State private var items: [String] = [Old Item] va
1
0
117
Sep ’25
Reply to Bug Report: SwiftUI @State Array Assignment Fails to Trigger UI Updates. Presumably when lengths of the old and new arrays are the same.
SwiftUI’s re-rendering depends on how identity is represented in your data. Use a stable and unique id to ensure your SwiftUI View update when the underlying data changes In a ForEach, the id parameter serves as that identifier. It must be Hashable, since SwiftUI uses it to track and assign identity to the views generated from each element in the collection. I recommend watching WWDC 2021 session— Demystify SwiftUI to learn more about SwiftUI lifecyle.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to How To Position Controls With SwiftUI
I personally find that placing precisely objects is a critical limit (or constraint) with SwiftUI. What I do (sometimes with mixed results) is to group objects in separate Views (red-bordered in the image). It makes it easier to position objects (with HStack / VStack) in each view and then position the views. Hope that helps.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Trouble with contextMenu previewing high resolution images
When using a contextMenu in SwiftUI to show a preview of a PHAsset’s full-size image via PHCachingImageManager.requestImage(), memory usage increases with each image preview interaction. The memory is not released, leading to eventual app crash due to memory exhaustion. The thumbnail loads and behaves as expected, but each call to fetch the full-size image (1000x1000) for the contextMenu preview does not release memory, even after cancelImageRequest() is called and fullSizePreviewImage is set to nil. The issue seems to stem from the contextMenu lifecycle behavior, it triggers .onAppear unexpectedly, and the full-size image is repeatedly fetched without releasing the previously loaded images. The question is, where do I request to the get the full-size image to show it in the context menu preview? STEPS TO REPRODUCE 1/ Create a SwiftUI LazyVGrid displaying many PHAsset thumbnails using PHCachingImageManager. 2/ Add a .contextMenu to each thumbnail button with: .onAppear that triggers requestI
2
0
121
Sep ’25
RC Pro Timeline Notification Not Received in Xcode
I'm having a heck of a time getting this to work. I'm trying to add an event notification at the end of a timeline animation to trigger something in code but I'm not receiving the notification from RC Pro. I've watched that Compose Interactive 3D Content video quite a few times now and have tried many different ways. RC Pro has the correct ID names on the notifications. I'm not a programmer at all. Just a lowly 3D artist. Here is my code... import SwiftUI import RealityKit import RealityKitContent extension Notification.Name { static let button1Pressed = Notification.Name(button1pressed) static let button2Pressed = Notification.Name(button2pressed) static let button3Pressed = Notification.Name(button3pressed) } struct MainButtons: View { @State private var transitionToNextSceneForButton1 = false @State private var transitionToNextSceneForButton2 = false @State private var transitionToNextSceneForButton3 = false @Environment(AppModel.self) var appModel @Environment(.dismissWindow) var dismissWindow //
5
0
399
Sep ’25
Reply to tabViewBottomAccessory AttributeGraph cycles, broken behavior of views participating in cycles
Xcode Version 26.0 (17A324) iOS 26.0 (23A343) Affects both devices (iPhone 16 Pro) and simulator (iPhone 17 Pro) Here's an example that demonstrates how these AttributeGraph: cycle logs are correlated with broken / unexpected behavior of views involved in the cycle. Clicking on the Button to toggle showOptionA doesn't update which Slider is displayed: import SwiftUI struct ContentView: View { var body: some View { TabView { Tab(Home, systemImage: house) { DemoView(prefix: Home) } Tab(Alerts, systemImage: bell) { DemoView(prefix: Alerts) } TabSection(Categories) { Tab(Climate, systemImage: fan) { DemoView(prefix: Climate) } Tab(Lights, systemImage: lightbulb) { DemoView(prefix: Lights) } } } .tabViewBottomAccessory { MusicPlaybackView() } .tabBarMinimizeBehavior(.onScrollDown) } } struct DemoView: View { let prefix: String var body: some View { List(0..<50, id: .self) { i in Text((prefix) Item #(i + 1)) } } } struct MusicPlaybackView: View { @Environment(.tabViewBottomAccessoryPlacement) var placem
Topic: UI Frameworks SubTopic: SwiftUI
Sep ’25
I need help
I am trying to learn to write swift. I am very proficient MS VB, which I have been using for almost 20 years. The Book I am learning from is: SwiftUI for Masterminds. I have got to chapter 7 with no problem. The exercise I am having a problem with Listing 7-5. The error I am getting is: Thread 1: Fatal error: No Observable object of type ApplicationData found. A View.environmentObject(_:) for ApplicationData may be missing as an ancestor of this view. I have spent the last 2 days rechecking my code. The MacBook I am using was purchased in May this year, is 16 in, M4 Max chip, 128 G ram. Firstly I want to thank you for reading this post. Secondly is there a better book to learn SwiftUI. Regards Terry Harrison
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2
0
204
Sep ’25