Post

Replies

Boosts

Views

Activity

SwiftUI custom focusable view cannot acquire focus programmatically on iPad with a hardware keyboard connected
On iPad, a SwiftUI view using .focusable(interactions: .edit) and .focused($isFocused) cannot acquire focus when a hardware keyboard is already connected. Setting isFocused = true from a button leaves it false. Tapping the view also leaves it unfocused, although the tap is received. Pressing Tab can focus the same view. struct FocusProbeView: View { @FocusState private var isFocused: Bool var body: some View { VStack { Text("Target") .focusable(interactions: .edit) .focused($isFocused) .onTapGesture { print("Target tapped") } Text("isFocused = \(isFocused)") Button("Focus target") { isFocused = true } } .defaultFocus($isFocused, true) } }Steps to reproduce: Run this view on an iPad with a hardware keyboard connected. Tap “Focus target”, then tap “Target”. Observe that isFocused remains false. Press Tab. The target can receive focus through keyboard navigation. Disconnect the keyboard. Restart the app and tap “Focus target” again. isFocused becomes true. Reconnecting the keyboard does not remove that focus. Expected: A visible custom view marked .focusable(interactions: .edit) can receive focus through @FocusState, including when a hardware keyboard is connected. Actual: Programmatic focus fails when the keyboard is already connected. A native TextField tested with the same button and @FocusState does receive focus. Environment: iPad model: MU1V2NF/A; iPadOS version: 26.7.2; Xcode version: 27.2; hardware keyboard: Logi Folio Touch. iPad model: Device Hub iPad Pro 11-inch (M5); iPadOS version: 27.2; Xcode version: 27.2; hardware keyboard: Device Hub.
1
0
249
1w
Inversed swipe gesture in VStack/LazyVStack vs List
I'm using a row swipe to delete gesture in a LazyVStack just the same way I would do in a List and I have to inverse the gesture (from left to right) to allow the Delete button appearing whereas in a List, the left to right swipe gesture works as expected. The following code reveals that unexpected/anti natural behavior. iOS works as expected for the same code. import SwiftUI import Playgrounds struct ContentView: View { var body: some View { VStack { // anti-natural and inconsistent gesture // LazyVStack { // anti-natural and inconsistent gesture // List { // natural gesture HStack { Text("Swipe Test") Spacer() } .padding(10) .frame(height: 40) .background { Color.blue } .swipeActions(edge: .trailing, allowsFullSwipe: false) { Button("Delete", role: .destructive) {} } } } }Setup: Macbook Pro M1 Max / macOS 27.2.1 / Xcode 27.2
0
0
51
1w
Cannot delete iOS 18.1 Simulator
When I try to delete an iPhone 16 Pro iOS 18.1 Simulator in XCode 16.1, I get an error message "“data” couldn’t be moved because you don’t have permission to access “Deleting-8366D3CC-37EC-49C0-8674-0599BCE1DA12”.". I had that same issue with iOS 18.0 Simulator but never with previous versions (17.5). Note that I'm stuck using the iOS 18.1 Simulator because iCloud synchronization is paused (potentially due to low data mode). And I cannot use iOS 18.0 Simulator as well because unit tests run hangs for some other mysterious reason. The fallback to iOS 17.5 Simulator is not satisfactory.
2
4
2.7k
Nov ’24
SwiftUI custom focusable view cannot acquire focus programmatically on iPad with a hardware keyboard connected
On iPad, a SwiftUI view using .focusable(interactions: .edit) and .focused($isFocused) cannot acquire focus when a hardware keyboard is already connected. Setting isFocused = true from a button leaves it false. Tapping the view also leaves it unfocused, although the tap is received. Pressing Tab can focus the same view. struct FocusProbeView: View { @FocusState private var isFocused: Bool var body: some View { VStack { Text("Target") .focusable(interactions: .edit) .focused($isFocused) .onTapGesture { print("Target tapped") } Text("isFocused = \(isFocused)") Button("Focus target") { isFocused = true } } .defaultFocus($isFocused, true) } }Steps to reproduce: Run this view on an iPad with a hardware keyboard connected. Tap “Focus target”, then tap “Target”. Observe that isFocused remains false. Press Tab. The target can receive focus through keyboard navigation. Disconnect the keyboard. Restart the app and tap “Focus target” again. isFocused becomes true. Reconnecting the keyboard does not remove that focus. Expected: A visible custom view marked .focusable(interactions: .edit) can receive focus through @FocusState, including when a hardware keyboard is connected. Actual: Programmatic focus fails when the keyboard is already connected. A native TextField tested with the same button and @FocusState does receive focus. Environment: iPad model: MU1V2NF/A; iPadOS version: 26.7.2; Xcode version: 27.2; hardware keyboard: Logi Folio Touch. iPad model: Device Hub iPad Pro 11-inch (M5); iPadOS version: 27.2; Xcode version: 27.2; hardware keyboard: Device Hub.
Replies
1
Boosts
0
Views
249
Activity
1w
Inversed swipe gesture in VStack/LazyVStack vs List
I'm using a row swipe to delete gesture in a LazyVStack just the same way I would do in a List and I have to inverse the gesture (from left to right) to allow the Delete button appearing whereas in a List, the left to right swipe gesture works as expected. The following code reveals that unexpected/anti natural behavior. iOS works as expected for the same code. import SwiftUI import Playgrounds struct ContentView: View { var body: some View { VStack { // anti-natural and inconsistent gesture // LazyVStack { // anti-natural and inconsistent gesture // List { // natural gesture HStack { Text("Swipe Test") Spacer() } .padding(10) .frame(height: 40) .background { Color.blue } .swipeActions(edge: .trailing, allowsFullSwipe: false) { Button("Delete", role: .destructive) {} } } } }Setup: Macbook Pro M1 Max / macOS 27.2.1 / Xcode 27.2
Replies
0
Boosts
0
Views
51
Activity
1w
Cannot delete iOS 18.1 Simulator
When I try to delete an iPhone 16 Pro iOS 18.1 Simulator in XCode 16.1, I get an error message "“data” couldn’t be moved because you don’t have permission to access “Deleting-8366D3CC-37EC-49C0-8674-0599BCE1DA12”.". I had that same issue with iOS 18.0 Simulator but never with previous versions (17.5). Note that I'm stuck using the iOS 18.1 Simulator because iCloud synchronization is paused (potentially due to low data mode). And I cannot use iOS 18.0 Simulator as well because unit tests run hangs for some other mysterious reason. The fallback to iOS 17.5 Simulator is not satisfactory.
Replies
2
Boosts
4
Views
2.7k
Activity
Nov ’24