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.

All subtopics

Post

Replies

Boosts

Views

Activity

SwiftUI ScrollView scroll gesture doesn't work on macOS but works on iOS(Mac Catalyst)
The title says it all, I'm using SwiftUI for multiplatform app, and I'm using ScrollView in it. My app has player bar which tracks the AVPlayer's current time. I made it using .offset(y:). The problem here is that whenever I change offset, the scroll gesture suddenly doesn't work on macOS. Video link: https://streamable.com/euzuwk But weirdly, it works on Mac Catalyst version. Video link: https://streamable.com/oq01mt The source code is on GitHub. I tried using Animation, but it made the player bar and music out of sync. So right now I made a publisher based on AVPlayer's addPeriodicTimeObserver and receiving the time from AVPlayer but now the scroll doesn't work as expected.
0
0
106
1d
SwiftData error when trying to save array in Model
In my SwiftData @Model I have an attribute attachments: [String]? and I'm getting an error when trying to save it: CoreData: fault: Could not materialize Objective-C class named "Array" from declared attribute value type "Array<String>" of attribute named attachments. Getting this error periodically on iOS 18 Beta 7 on iPhone, but the same code works on iPadOS 18 b7 and on macOS Sonoma (14.6.1) Anyone seen this?
2
0
134
2d
App Icon all black on ios17, works on iOS18, building app in Xcode16 beta
In my app I added an AppIcon in the Assets.xcassets folder. I added a any/dark/tinted version of the app icon, in 1024x1024 resolution as a HEIC file, specifying a "single size" iOS option. When I build and run the app in xcode16 beta on iOS18 the icon works as expected, but when I run the same app on iOS17 the icon just shows up as a black rectangle. How do I get the app icon to work correctly on both iOS18 and iOS17?
1
0
99
2d
Change in behavior for .isToggle trait
One of my blind users reached out to me after they updated to iPadOS 18. I have a button that is used to mark/unmark a favorite location. He said that he could still tell the favorite status via the label and hint, but VoiceOver was always saying that the switch button is off. I'm able to recreate this on my iPad as well. The documentation for .isToggle is completely blank. Basically with iPadOS 17 adding the .isToggle trait makes VoiceOver state that my button is a toggle. With iPadOS 18 adding the .isToggle trait makes VoiceOver state that my button is a toggle AND try to state its current value. I don't know if this is intentional or a bug. Button { showFavActions() } label: { Image(systemName: SFSymbolShortcut.star.rawValue) .symbolVariant(weatherData.currentlyFavIndex == nil ? .none : .fill) } .buttonStyle(.plain) .accessibilityLabel(Text(weatherData.currentlyFavIndex == nil ? "Not a favorite location." : "Favorite location.")) .accessibilityHint(Text(weatherData.currentlyFavIndex == nil ? "Add to favorites." : "Remove from favorites.")) .accessibilityInputLabels(["Favorite"]) .accessibilityAddTraits(.isToggle) // iOS 17
1
0
104
2d
iOS 18 Beta UIPrintInteractionController present issue
I have a UIViewController that presents a UIPrintInteractionController when a user selects the print button on the UI. The problem is starting in iOS 18 (currently using beta 7) when the print controller is presented the UIViewController's viewWillAppear() is being called. This did not happen in earlier iOS releases and is causing unwanted behavior in the app. Is this a bug or will this be the behavior going forward?
1
0
86
2d
Hiding the NavigationSplitView's sidebar border.
I'm trying to build a custom designed sidebar for iPad that requires there to be no gray divider to separated the navigation and the detail view. I'm surprised at how unsuccessful I have been given how simple this is but have still found no luck. My current code: struct ContentView: View { var body: some View { NavigationSplitView { VStack { //code... } .background(.white) .navigationSplitViewColumnWidth(70) .navigationBarHidden(true) .edgesIgnoringSafeArea(.vertical) } detail: { //code... } } } I've attempted to add an overlay of a white rectangle to cover the divider but it just goes behind the existing border. I like to think there is a simpler solution anyways.
1
0
99
2d
ControlWigdet Open APP with URL
This code can open app, but the deep link is not send to the app. It doesn't seem to call the UIApplicationDelegate's "application(_:open:options:)" method, so I can't read the link string that was passed in func perform() async throws -> some IntentResult & OpensIntent { guard let url = URL(string: "myapp://myappintent") else { // throw an error of your choice here } return .result(opensIntent: OpenURLIntent(deepLink)) }
0
0
58
2d
ControlWidget Can't use onOpenURL
`struct OpenMainAppIntent: AppIntent { static let title: LocalizedStringResource = "OpenMainAppIntent" static var openAppWhenRun: Bool = true init() {} @MainActor func perform() async throws -> some IntentResult & OpensIntent { guard let url = URL(string: "myapp://open") else { throw OpenURLError.invalidURL } return .result(opensIntent: OpenURLIntent(url)) } } ` This is an action in my custom control widget, and i want to use this deeplink open my application and get the link's info, but it won't perform onOpenURL `@main struct TestControlWidgetApp: App { var body: some Scene { WindowGroup { ContentView() .onOpenURL { url in print("url: \(url)") } } } }`
0
0
49
2d
ScrollView content ignores taps near UIViewControllerRepresentable
As the title says, when a ScrollView is near a UIViewControllerRepresentable, then the ScrollView's content no longer accurately recognizes taps. In particular, taps along the leading edge (10 points-ish) are ignored. Here's a working example: struct ContentView: View { var body: some View { HStack(spacing: 0) { MyRepresentable() // .allowsHitTesting(false) ScrollView { LazyVStack { ForEach(0..<10, id: \.self) { index in HStack(spacing: 0) { Button { print("tapped \(index)") } label: { Color.red } .frame(width: 50) Color.blue } .frame(height: 50) } } } } } } Here's the representable and a placeholder controller: struct MyRepresentable: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> MyViewController { MyViewController() } func updateUIViewController(_ uiViewController: MyViewController, context: Context) {} } final class MyViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .gray } } When you tap along the leading edge of the red buttons, the taps are ignored for about the first 10 points. But if you prevent hit testing on the representable (by un-commenting the .allowsHitTesting modifier), then the red buttons behave as expected. Also if you just remove the representable entirely, then all the buttons behave as expected. It's as if the hit targets of the buttons are getting "pushed" over by the representable. Or is the representable simply intercepting these touches? I've confirmed this incorrect behavior on iPad via touch and mouse. However, Apple Pencil (1st gen) and Apple Pencil Pro behave correctly - even in the presence of that UIViewControllerRepresentable. Perhaps the Pencil follows a different hit-test codepath? Is this expected behavior? If so, then how do I use UIViewControllerRepresentable and ScrollView side-by-side?
2
0
53
2d
iOS 18 Navigation Title Bug
Hello. I'm encountering a strange behavior in iOS 18 and wanted to ask about it. When I run the following code on iOS 18, quotation marks appear in the navigation title. class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.title = " " self.view.backgroundColor = .systemBlue } } In versions prior to iOS 18, the title is displayed as intended, with nothing showing up. Could this be an intentional change in iOS 18, or is it a bug?
2
0
121
3d
minimumScaleFactor for Text in widgets scales the text.
Hi, In my widgets, I use minimumScaleFactor to ensure that my text is readable. In iOS 18.0 beta 6 and iOS18.0 beta 7, my texts suddenly became very small. It seems that minimumScaleFactor acts like if it was applying the given scale value to the text. minimumScaleFactor(0.1) seems to display the text 90% smaller than the text without calling minimumScaleFactor. minimumScaleFactor(0.5) seems to display the text 50% smaller than the text without calling minimumScaleFactor. Is this a bug, of is there an unexpected change in the API ? Edit : I have created FB14890220, in case this message remains unseen.
2
0
111
3d
Error in Hierarchical Table or list in MAC OS but not iOS
If I use the example code I find in the Quick help for LIST (Creating hierarchical lists) in MAC OS 15.1, I get an error, but not in IOS 18.1. The error happens when I try to Compact any Item I had expanded. If I use a table instead I also get an error, But If I use outline group without list there is not error struct ContentView: View { struct FileItem: Hashable, Identifiable, CustomStringConvertible { var id: Self { self } var name: String var children: [FileItem]? = nil var description: String { switch children { case nil: return "📄 \(name)" case .some(let children): return children.isEmpty ? "📂 \(name)" : "📁 \(name)" } } } let fileHierarchyData: [FileItem] = [ FileItem(name: "users", children: [FileItem(name: "user1234", children: [FileItem(name: "Photos", children: [FileItem(name: "photo001.jpg"), FileItem(name: "photo002.jpg")]), FileItem(name: "Movies", children: [FileItem(name: "movie001.mp4")]), FileItem(name: "Documents", children: []) ]), FileItem(name: "newuser", children: [FileItem(name: "Documents", children: []) ]) ]), FileItem(name: "private", children: nil) ] var body: some View { List(fileHierarchyData, children: \.children) { item in Text(item.description) } } }
0
0
73
3d
iOS 18 new ControlWidgetButton custom image/icon/symbol not displayed
Hello, I am trying to create a custom control with the new WidgetKit control widget APIs. In my custom control, I want to display a custom image, in fact a custom symbol. The custom symbol is not displayed with latest iOS 18 Seed 7 (22A5346a). Only system symbols are displayed. I don't find any information about it in the WidgetKit Apple Developer Documentation. ControlWidgetButton(action: MyIntent()){ Label(title: { Text("My Custom Control") }, icon: { Image("mycustomsymbol") //NOT DISPLAYED // Image(systemName: "rectangle.portrait.inset.filled") IS DISPLAYED }) } There was no issue with custom symbols in beta 4. Now since beta 5, custom symbols are not displayed. I wonder if this is a bug or this is intended. Can you help me ? I filed a feedback FB14888220 Thank you
1
1
101
3d
Issues with persistent SwiftUI.AppSceneDelegate causing black screen on app launch
For a few reasons, we as a team decided to transition away from the SwiftUI.App launch cycle. We need more control and customisation, and managing the scenes directly ourselves was the best way forward. We're now trying to run the app entirely from our own App and Scene delegates, however we've run into a problem: When we update the app on a device from a version that uses SwiftUI.App to a version that uses App and Scene delegates, the first initial launch fails with a black screen. The reason for this is that FrontBoardServices attempts to use the existing UISceneSession after the update, with the SwiftUI.AppSceneDelegate class, instead of calling application(configurationForConnecting:options:). Since SwiftUI.AppSceneDelegate still exists in the scope, the internal property _configurationNeedsReevaluation on UISceneSession returns false and the app attempts to launch from SwiftUI.AppSceneDelegate. As far as I can tell, there doesn't seem to be a way to fix this that doesn't involve invoking the private method -[UISceneSession _updateConfiguration:] to force the configuration to use the correct Scene delegate. if let sceneSession = application.openSessions.first( where: { $0.configuration.delegateClass.map(NSStringFromClass) == "SwiftUI.AppSceneDelegate" } ) { let newConfig = UISceneConfiguration(name: nil, sessionRole: .windowApplication) newConfig.delegateClass = SceneDelegate.self sceneSession.perform(Selector(("_updateConfiguration:")), with: newConfig) } Could you maybe advise on a way forwards?
1
0
90
3d
SwiftData multiple loop entries not inserting
For an array only the last row is inserted where print shows the loop is processed for index in 0..<model.dataTable!.rows.count { let row = model.dataTable!.rows[index] catagory.name = row["Catagory"] as! String context.insert(catagory) print(catagory.name) } tried a forced try?save() which didn't help Thanks Joel
3
0
78
3d