Search results for

swiftui

16,580 results found

Post

Replies

Boosts

Views

Activity

WebView makes website content unaccessible on the top/bottom edges
I'm being faced with an issue when using SwiftUI's WebView on iOS 26. In many websites, the top/bottom content is unaccessible due to being under the app's toolbars. It feels like the WebView doesn't really understand the safe areas where it's being shown, because the content should start right below the navigation bar, and only when the user scrolls down, the content should move under the bar (but it's always reachable if the users scroll back up). Here's a demo of the issue: Here's a 'fix' by ensuring that the content of the WebView never leaves its bounds. But as you can see, it feels out of place on iOS 26 (would be fine on previous OS versions if you had a fully opaque toolbar): Code: struct ContentView: View { var body: some View { NavigationStack { WebView(url: URL(string: https://apple.com)).toolbar { ToolbarItem(placement: .primaryAction) { Button(Top content covered, unaccessible.) {} } } } } } Does anyone know if there's a way to fix it using some sort of view modifier combination or it's
14
0
486
4d
Reply to WebView makes website content unaccessible on the top/bottom edges
@DTS Engineer Do you know if there's any progress on a fix for it or if there's any workaround? I tried injecting custom CSS, but that breaks many websites, and I can't be adding custom code for every single website out there 🤪 The bottom safe area seems to work as expected, the problem is just at the top with the navigation bar + top safe area. Here's a quick sample code that can be pasted anywhere to run and observe the issue on three different websites: import WebKit import SwiftUI @main struct WebViewSafeAreaApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { let urls: [URL] = [ URL(string: https://mastodon.social)!, URL(string: https://substack.com)!, URL(string: https://apple.com)! ] @State private var selection: URL? var body: some View { NavigationSplitView { List(selection: $selection) { ForEach(urls, id: .absoluteString) { url in Text(url.absoluteString).tag(url) } } .navigationTitle(Sidebar) .navigationBarTitleDisplayMode(.inline) } detail: { if
Topic: UI Frameworks SubTopic: SwiftUI Tags:
4d
Navigation title flickers when tab is changed when used with a List / Form
Problem When a List / Form is added inside a TabView and navigationTitle is set, then switching between tabs causes the navigation title to flicker. Feedback: FB21436493 Environment Xcode: 26.2 (17C52) iOS: 26.2 (23C55) Reproducible on: Both simulator and device Root cause When List / Form is commented out, issue doesn't occur Steps to Reproduce Run app on iOS Switch between tabs Notice that the navigation title flickers Code ContentView import SwiftUI struct ContentView: View { @State private var selectedTab = TabItem.red var body: some View { NavigationStack { TabView(selection: $selectedTab) { ForEach(TabItem.allCases, id: .self) { tab in Tab(tab.rawValue, systemImage: tab.systemImageName , value: tab) { // Problem occurs with a List / Form // Commenting out list works without flickering title List { Text(tab.rawValue) } } } } .navigationTitle(selectedTab.rawValue) } } } TabItem enum TabItem: String, CaseIterable { case red case green case blue var systemImageName: String { switch self { case .red
Topic: UI Frameworks SubTopic: SwiftUI
3
0
255
5d
Button Touch Not Canceled in ScrollView on Modal in SwiftUI for iOS 18
When displaying a view with a Button inside a ScrollView using the sheet modifier, if you try to close the sheet by swiping and your finger is touching the Button, the touch is not canceled. This issue occurs when building with Xcode 16 but does not occur when building with Xcode 15. Here is screen cast. https://drive.google.com/file/d/1GaOjggWxvjDY38My4JEl-URyik928iBT/view?usp=sharing Code struct ContentView: View { @State var isModalPresented: Bool = false var body: some View { ScrollView { Button { debugPrint(Hello) isModalPresented.toggle() } label: { Text(Hello) .frame(height: 44) } Button { debugPrint(World) } label: { Text(World) .frame(height: 44) } Text(Hoge) .frame(height: 44) .contentShape(Rectangle()) .onTapGesture { debugPrint(Hoge) } } .sheet(isPresented: $isModalPresented) { ContentView() } } }
15
0
2.7k
6d
Keyboard Toolbar Padding iOS26
When I create a SwiftUI toolbar item with placement of .keyboard on iOS 26, the item appears directly on top of and in contact with the keyboard. This does not look good visually nor does it match the behavior seen in Apple's apps, such as Reminders. Adding padding to the contents of the toolbar item only expands the size of the item but does not separate the capsule background of the item from the keyboard. How can I add vertical padding or spacing to separate the toolbar item capsule from the keyboard?
Topic: UI Frameworks SubTopic: SwiftUI
8
0
614
6d
App Widget NSExtensionPrincipalClass found in extension Info.plist
My app is built in flutter and has a native Widget in it. The widget's Info.plist file has the NSExtensionPrincipalClass key that links to the VerseOfTheDayWidgetBundle as string. However the Transport app throws an error: Validation failed (409) Unexpected Info.plist key. Unexpected key NSExtensionPrincipalClass found in extension Info.plist for Payload/Runner.app/PlugIns/VerseOfTheDayWidgetExtension.appex. (ID: 266e2dd8-44b9-4d67-97d9-d7d47013cff9) Now I tried removing the NSExtensionPrincipalClass and but the simulator throws an error asking for the NSExtensionPrincipalClass or Storyboard class but my widget is completely written in SwiftUI and does not have a storyboard which is why I am using the NSExtensionPrincipalClass. I tried to bypass this by creating two info.plist files for my widget (debug and release) this bypassed the security check on Transporter but then the app wouldn't install in TestFlight confirming the same issue as the simulator. I can confirm that my app's info.plist does not
2
0
191
1w
Reply to SwiftUI @State Updates Not Reflecting in UI Until View Reconstruction (Xcode Preview & Device)
Update: Issue Resolved! 🎉 Thanks again for testing on your setup! Your feedback helped me realize this might be an environment-specific issue. Root Cause Found After extensive debugging, I identified two key problems: Performance bottleneck during initialization: A utility manager was making repeated I/O calls on every UI update, flooding the console with 100+ log statements on first load. SwiftUI subscription mechanism timing: In Xcode Preview (specifically on macOS 26.1 + Xcode 26.2), when the main thread is heavily loaded during ContentView initialization, the @State → View update subscription doesn't properly establish. Solution Part 1: Performance optimization Added caching for expensive operations Removed excessive logging (100+ lines → 3 lines) Pre-loaded resources instead of loading on-demand Part 2: Preview-specific fix struct ContentView: View { @State private var refreshTrigger: Int = 0 var body: some View { // ... content .id(refreshTrigger) // Force rebuild when id changes .onAppear { /
Topic: UI Frameworks SubTopic: SwiftUI
1w
SwiftUI @State Updates Not Reflecting in UI Until View Reconstruction (Xcode Preview & Device)
Issue Description I'm experiencing a bizarre SwiftUI state update issue that only occurs in Xcode development environment (both Canvas preview and device debugging), but does not occur in production builds downloaded from App Store. Symptom: User taps a button that modifies a @State variable inside a .sheet Console logs confirm the state HAS changed But the UI does not update to reflect the new state Switching to another file in Xcode and back to ContentView instantly fixes the issue The production build (same code) works perfectly fine Environment Xcode: 16F6 (17C52) iOS: 26.2 (testing on iPhone 13) macOS: 25.1.0 (Sequoia) SwiftUI Target: iOS 15.6+ Issue: Present in both Xcode Canvas and on-device debugging Production: Same code works correctly in App Store build (version 1.3.2) Code Structure Parent View (ContentView.swift) struct ContentView: View { @State private var selectedSound: SoundTheme = .none @State private var showSoundSheet = false var body: some View { VStack { // Display butt
Topic: UI Frameworks SubTopic: SwiftUI
6
0
338
1w
SwiftData .autosaveEnabled / rollback() trouble
Hello, In my iOS/SwiftUI/SwiftData app, I want the user to be able to hit [Cancel] from editing in a detail screen and return to the previous screen without changes being saved. I believed that setting autosaveEnabled to false and/or calling .rollback would prevent changes from being saved, unless/until I call .save() when the user clicks [Save], but this does not seem to be correct. I set modelContext.autosaveEnabled = false and I call modelContext.rollback() when the user hits [Cancel], but any changes they made are not rolled back, but saved even if I don’t call save(). I have tried setting autosaveEnabled to false when I create the ModelContainer on a @MainActor function when the App starts, and in the detail/edit screen’s .onAppear(). I can see that .rollback is being called when the [Cancel] button is tapped. In all cases, any changes the user made before hitting [Cancel] are saved. The Developer Documentation on autosaveEnabled includes this: “The default value is false. SwiftData automaticall
4
0
147
1w
Keyframe animation crashes with +[_SwiftUILayerDelegate _screen]: unrecognized selector sent to class on iOS 26
We have an UIViewController called InfoPlayerViewController. Its main subview is from a child view controller backed by SwiftUI via UIHostingController. The InfoPlayerViewController conforms to UIViewControllerTransitioningDelegate. The animation controller for dismissing is DismissPlayerAnimationController. It runs UIKit keyframe animations via UIViewPropertyAnimator. When the keyframe animation is executed there’s an occasional crash for end users in production. It only happens on iOS 26. FB Radar: FB20871547 An example crash is below. Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Reason: +[_SwiftUILayerDelegate _screen]: unrecognized selector sent to class 0x20c95da08 Termination Reason: SIGNAL 6 Abort trap: 6 Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x1a23828c8 __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x19f2f97c4 objc_exception_throw + 88 (objc-exception.mm:356) 2 CoreFoundation 0x1a241e6cc +
3
0
408
1w
DeviceActivity Report Extension cannot pass App Store Connect validation without becoming un-installable on device
I'm running into a contradictory requirement involving the DeviceActivity Report extension (com.apple.deviceactivityui.report-extension) that makes it impossible to both: upload the app to App Store Connect, and install the app on a physical device. This creates a complete catch-22. 📌 Overview My extension: Path: Runner.app/PlugIns/LoADeviceActivityReport.appex Extension point: com.apple.deviceactivityui.report-extension Implementation (SwiftUI): import SwiftUI import DeviceActivity @main struct LoADeviceActivityReport: DeviceActivityReportExtension { var body: some DeviceActivityReportScene { // ... } } This is the standard SwiftUI @main DeviceActivityReportExtension template. 🟥 Side A — iOS runtime behavior (device installer) If I add either of these keys to the extension's Info.plist: NSExtensionPrincipalClass NSExtensionMainStoryboard then the app cannot be installed on a real iPhone/iPad. The device installer fails with: Error 3002 AppexBundleContainsClassOrStoryboard NSExten
3
0
178
1w
Reply to SwiftUI @State Updates Not Reflecting in UI Until View Reconstruction (Xcode Preview & Device)
Thanks for your reply! Here's the complete code and detailed information: Issue Description I'm experiencing a strange behavior with Xcode Preview in my SwiftUI app: On first Preview load: Button taps don't respond at all Temporary workaround: Click any other file, then click back to ContentView - buttons work perfectly Reproducibility: Happens 100% of the time after cleaning and restarting Preview Environment Xcode Version: Version 26.2 iOS Target: iOS 26.1 macOS Version: 26.1 Reproducibility: 100% consistent Relevant Code App Entry Point import SwiftUI import AVFoundation @main struct MyApp: App { init() { setupAudioSession() } private func setupAudioSession() { do { try AVAudioSession.sharedInstance().setCategory( .playback, mode: .default, options: [.mixWithOthers] ) try AVAudioSession.sharedInstance().setActive(true) } catch { print(Failed to setup audio session: (error)) } } var body: some Scene { WindowGroup { ContentView() } } }### ContentView - Simplified Version import SwiftUI
Topic: UI Frameworks SubTopic: SwiftUI
1w
Reply to findNavigator
I'm coding in swiftUI. I've a TextEditor. When I make appear the findNavigator of this TextEditor I want to copy a string to the searchText by program when it appears. I think it's possible to copy this string to the findNavigator but I don't know how to do this. Perhaps sending a copy command to the view ancestor ?
1w