If I add items at the root level, this code works, but if I attempt to add a child to any item, it runs an infinite loop where it goes from the AddItemView back to the SubItemView and starts all over. I suspect it has something to do with the Predicate in SubItemView, but the debugger is crap, so I'm just guessing.
Minimal code:
@Model
final class Item {
var id: String
var name: String
var children: [Item] = []
@Relationship(deleteRule: .cascade) var parent: Item?
init(name: String, parent: Item?, id: String = UUID().uuidString) {
self.name = name
self.parent = parent
self.id = id
}
}
struct ContentView: View {
@Environment(\.modelContext) private var modelContext
@Query(
filter: #Predicate<Item> {
item in
item.parent == nil
}, sort: \Item.name
) public var rootItems: [Item]
var body: some View {
NavigationStack {
List {
ForEach(rootItems) { item in
HStack {
NavigationLink ( destination: SubItemView(parent: item)) {
Text(item.name) }
}
}
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
EditButton()
}
ToolbarItem {
NavigationLink(destination: AddItemView(itemParent: nil)) {
Text("Add To Do")
}
}
}
}
}
}
struct SubItemView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.modelContext) private var modelContext
@State var parent: Item
@State private var todo: String = ""
@State var selectedDate = Date()
@State var showPicker: Bool = false
@Query var children: [Item]
init(parent: Item) {
self.parent = parent
let parentID = parent.id
_children = Query(filter: #Predicate<Item> {
$0.parent.flatMap(\.id) == parentID && $0.parent.flatMap(\.id) != nil
}, sort: \Item.name )
}
var body: some View {
Form {
LabeledContent {
TextField("Name", text: $parent.name)
} label: {
Text("Name:")
}
}
Text("Parent: \(parent.name)\n")
NavigationStack {
Text("Child count: \(children.count)")
List(children) { child in
HStack {
if(child.children.isEmpty) {
Text(child.name)
NavigationLink ( destination: SubItemView(parent: child)) {
Text("").foregroundColor(.white).background(Color.blue)
}
.opacity(0)
.background(
Text("")
)
} else {
Text(child.name)
NavigationLink(destination: SubItemView(parent: child)) {
Text("")
}
}
}
}
}
.navigationTitle("Sub Items")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
EditButton()
}
ToolbarItem {
NavigationLink(destination: AddItemView(itemParent: parent)) {
Text("Add To Do")
}
}
ToolbarItem {
Button("Save") {
try? modelContext.save()
dismiss()
}
}
}
}
}
struct AddItemView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.modelContext) private var context
@State var itemParent: Item?
@State private var name = ""
@State private var showWarning: Bool = false
@State var child = Item(name: "", parent: nil)
var body: some View {
NavigationStack {
Form {
LabeledContent {
TextField("Item", text: $name)
} label: {
Text("Todo:")
}
}
.navigationTitle("Add New Item")
.toolbar {
Button("Save") {
let tmp = Item(name: name, parent: itemParent)
if(itemParent != nil) {
itemParent!.children.append(tmp)
}
context.insert(tmp)
try? context.save()
dismiss()
}
}
}
}
}
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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi all,
Is there way to check the status of multi-stage text input in the TextField of SwiftUI?
I am essentially trying to detect if the user is entering some text with multi-stage text input method right now. (e.g., Japanese, Chinese, etc).
TextField("Search", text: $searchText)
.onKeyPress(keys: [.upArrow, .downArrow]) { event in
if ....some condition here... {
// ignore up/down keys when multi-stage input
return .ignored
}
else {
// do some special key handling
// when multi-stage input is not running
return .handled
}
}
Multi-stage text input uses up/down keys to choose words from candidates, so I don't want to handle the keys when it is happening.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hi,
How to customize tables in SwiftUI its color background for example, the background modifier doesn't work ? how to change separator lines ? rows background colors ? give header row different colors to its text and background color ?
Kind Regards
Topic:
UI Frameworks
SubTopic:
SwiftUI
I don't know what triggered this in a previously-running application I'm developing: When I have the build target set to "My Mac (designed for iPad)," I now must delete all the app's build materials under DerivedData to get the app to build and run exactly once. Cleaning isn't enough; I have to delete everything.
On second launch, it will crash without even getting to the instantiation of the application class. None of my code executes.
Also: If I then set my iPhone as the build target, the app will build and run repeatedly. If I then return to "My Mac (designed for iPad)," the app will again launch once and then crash on every subsequent launch.
The crash is the same every time:
dyld[3875]: Symbol not found: _OBJC_CLASS_$_AVPlayerView
Referenced from: <D566512D-CAB4-3EA6-9B87-DBD15C6E71B3> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport.dylib
Expected in: <4C34313C-03AD-32EB-8722-8A77C64AB959> /System/iOSSupport/System/Library/Frameworks/AVKit.framework/Versions/A/AVKit
Interestingly, I haven't found any similar online reports that mention this symbol.
Has anyone seen this behavior before, where the crash only happens after the first run... and gets reset when you toggle the target type?
This problem will occur in Xcode 16 beta and iOS 18 beta, are there any changes to the function of highPriorityGesture in iOS 18?
Example code is:
import SwiftUI
struct ContentView: View {
@State private var dragable: Bool = false
@State private var dragGestureOffset: CGFloat = 0
var body: some View {
ZStack {
ScrollViewReader { scrollViewProxy in
ScrollView(showsIndicators: false) {
cardList
.padding(.horizontal, 25)
}
}
}
.highPriorityGesture(dragOffset)
}
var cardList: some View {
LazyVStack(spacing: 16) {
Text("\(dragGestureOffset)")
.frame(maxWidth: .infinity)
.padding(.vertical,8)
.background {
RoundedRectangle(cornerRadius: 8)
.fill(.gray)
}
//Display 100 numerical values in a loop
ForEach(0..<100) { index in
Text("\(index)")
.frame(maxWidth: .infinity)
.padding(.vertical,8)
.background {
RoundedRectangle(cornerRadius: 8)
.fill(.gray)
}
}
}
}
var dragOffset: some Gesture {
DragGesture()
.onChanged { value in
if abs(value.translation.width) > 25 {
dragable = true
dragGestureOffset = value.translation.width
}
}
.onEnded { value in
if abs(value.translation.width) > 25 {
dragable = false
dragGestureOffset = 0
}
}
}
}
When the APP is in the background, using AccessorySetupKit, calling showPicker is invalid. When I tested it before, it was valid on iOS 18.0, but it is invalid after updating to iOS 18.1.1. Is this a bug? Will it be fixed later?
Topic:
UI Frameworks
SubTopic:
UIKit
One of my SwiftUI applications using a Canvas view started to crash with Xcode 16. It was working flawlessly with Xcode 15. I was able to come up with a minimal SwiftUI app that shows the issue:
@main struct CanvasTest: App {
var body: some Scene {
WindowGroup {
VStack {
Canvas { context, size in
context.withCGContext { cgContext in
let z = Int(size.width / 3.0)
for i in 0..<18000 { // crashes from 17413 on
cgContext.beginPath()
cgContext.move(to: CGPoint(x: (i % z) * 3, y: (i / z) * 2))
cgContext.addLine(to: CGPoint(x: (i % z) * 3 + 2, y: (i / z) * 2))
cgContext.strokePath()
}
}
}
}
}
}
}
The canvas displays 18000 lines and the context.withCGContext invocation also completes successfully. Yet, the application crashes immediately after like this (details below):
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001800eabb4
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [2162]
I was wondering if anyone else noticed that change and found a way to fix it? Alternatively, I am looking for workarounds. I have to be able to display large drawings created via core context-based graphics.
Is this worth reporting to Apple?
Thanks already now for any help and advice.
Hardware Model: Mac15,9
Process: CanvasTest [2162]
Path: /Users/USER/Library/Developer/CoreSimulator/Devices/0C372C7C-3D00-48AA-8124-799CB9A35C1E/data/Containers/Bundle/Application/EBAEC7A2-C93D-48B7-9754-4F3F54A33084/CanvasTest.app/CanvasTest
Identifier: com.objecthub.CanvasTest
Version: 1.0 (1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd_sim [98324]
Coalition: com.apple.CoreSimulator.SimDevice.0C372C7C-3D00-48AA-8124-799CB9A35C1E [58431]
Responsible Process: SimulatorTrampoline [3499]
Date/Time: 2024-12-01 14:33:07.7617 +0100
Launch Time: 2024-12-01 14:33:07.4151 +0100
OS Version: macOS 15.1.1 (24B91)
Release Type: User
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001800eabb4
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [2162]
Triggered by Thread: 0
Application Specific Information:
Abort Cause 268435470
Thread 0 Crashed:: Dispatch queue: com.Metal.CommandQueueDispatch
0 libxpc.dylib 0x1800eabb4 _xpc_connection_release_message.cold.1 + 60
1 libxpc.dylib 0x1800c9910 _xpc_connection_release_message + 240
2 libxpc.dylib 0x1800c80b4 _xpc_connection_enqueue + 264
3 libxpc.dylib 0x1800c8b9c xpc_connection_send_message + 128
4 MTLSimDriver 0x2275c6e7c -[MTLSimCommandQueue submitCommandBuffers:count:] + 368
5 Metal 0x19eabdfd4 -[_MTLCommandQueue _submitAvailableCommandBuffers] + 480
6 Metal 0x19eabe4ac __40-[_MTLCommandQueue submitCommandBuffer:]_block_invoke + 24
7 libdispatch.dylib 0x180178de0 _dispatch_client_callout + 16
8 libdispatch.dylib 0x180188ac8 _dispatch_lane_barrier_sync_invoke_and_complete + 92
9 Metal 0x19eabe46c -[_MTLCommandQueue submitCommandBuffer:] + 112
10 MTLSimDriver 0x2275c5fc8 -[MTLSimCommandBuffer commitAndWaitUntilSubmitted] + 40
11 RenderBox 0x1c6e9015c RB::RenderFrame::~RenderFrame() + 240
12 RenderBox 0x1c6e6e9dc __38-[RBLayer displayWithBounds:callback:]_block_invoke.27 + 500
13 libdispatch.dylib 0x180178de0 _dispatch_client_callout + 16
14 libdispatch.dylib 0x180188ac8 _dispatch_lane_barrier_sync_invoke_and_complete + 92
15 RenderBox 0x1c6e6de38 -[RBLayer displayWithBounds:callback:] + 2480
16 RenderBox 0x1c6e6d46c -[RBLayer display] + 172
17 QuartzCore 0x18b0c7e74 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 392
18 QuartzCore 0x18affca50 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464
19 QuartzCore 0x18b02b260 CA::Transaction::commit() + 652
20 UIKitCore 0x185af0f70 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
21 CoreFoundation 0x18041b58c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
22 CoreFoundation 0x18041acc4 __CFRunLoopDoBlocks + 352
23 CoreFoundation 0x1804153cc __CFRunLoopRun + 812
24 CoreFoundation 0x180414c24 CFRunLoopRunSpecific + 552
25 GraphicsServices 0x19020ab10 GSEventRunModal + 160
26 UIKitCore 0x185ad82fc -[UIApplication _run] + 796
27 UIKitCore 0x185adc4f4 UIApplicationMain + 124
28 SwiftUI 0x1d290b41c closure #1 in KitRendererCommon(_:) + 164
29 SwiftUI 0x1d290b144 runApp<A>(_:) + 84
30 SwiftUI 0x1d266bef4 static App.main() + 148
31 CanvasTest.debug.dylib 0x105061c64 static CanvasTest.$main() + 40
32 CanvasTest.debug.dylib 0x105061d14 __debug_main_executable_dylib_entry_point + 12 (CanvasTest.swift:11)
33 dyld_sim 0x10519d410 start_sim + 20
34 dyld 0x10539a274 start + 2840
Thread 4:: com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x1050f5290 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1051066c4 mach_msg2_internal + 76
2 libsystem_kernel.dylib 0x1050fd3f4 mach_msg_overwrite + 536
3 libsystem_kernel.dylib 0x1050f55cc mach_msg + 20
4 CoreFoundation 0x18041b000 __CFRunLoopServiceMachPort + 156
5 CoreFoundation 0x180415528 __CFRunLoopRun + 1160
6 CoreFoundation 0x180414c24 CFRunLoopRunSpecific + 552
7 Foundation 0x180f319c8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208
8 Foundation 0x180f31be8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 60
9 UIKitCore 0x185b858c0 -[UIEventFetcher threadMain] + 404
10 Foundation 0x180f58810 __NSThread__start__ + 720
11 libsystem_pthread.dylib 0x10507f6f8 _pthread_start + 104
12 libsystem_pthread.dylib 0x10507a940 thread_start + 8
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hello,
I am working on an iOS app that has interactive components that react to the device accelerometer. The app works in landscape left and right only, and I need some way to identify if the screen is left or right to get the acceleration direction correct. Basically, accelerating to the device's "left" means you actually need to move the elements on screen to the left or right depending on screen direction.
One solution I tried is using UIDeviceOrientation. This works in most cases, but when screen lock is on, it gives an update about the device orientation when the screen itself didn't tilt.
Is there some other way to get the screen orientation that accurately reflects the screen orientation and not just device orientation?
Thank you.
I'm going through the tutorial and have copied the code given to me verbatim, but I am still getting the error 'Value of type 'SettingsView' has no member 'tabItem'. Not sure what to do. Code is below.
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
TabView {
ContentView()
.tabItem {
Label("Journal", systemImage: "book")
}
SettingsView()
.tabItem { *error is here - Value of type 'SettingsView' has no member 'tabItem'
Label("Settings", systemImage: "gear")
}
}
}
}
}
I have a widget with a dynamic property. I'm able to provide the options to the widget edit ui and the user can make their selection .. which filters what data gets shown in the widget.
My use case is when the user goes back to the main app and deletes the option that is currently selected. Currently, the widget keeps that selection. How can I get the widget to clear that selection and show the defaultResult() from the EntityQuery?
Hello, I am developing a service using capture sessions. I have a question concerning something curious I've noticed. Occasionally, I've been informed that the capture session stops working. Upon investigation, I found records of the videoDeviceNotAvailableWithMultipleForegroundApps interruption on the devices.
From what I've looked up in the documents, it seems to occur due to multitasking capabilities, but I'm wondering if there are any specific scenarios where this happens on iPhone devices? Here is the relevant documentation link: https://developer.apple.com/documentation/avfoundation/avcapturesession/interruptionreason/videodevicenotavailablewithmultipleforegroundapps
I suspect it might have something to do with Picture-in-Picture (PIP) mode, but when I developed and tested a direct video streaming PIP, the issue did not occur. Does anyone have insights on this matter or related experiences they could share?
I'm trying to configure the share sheet.
My project uses techniques from the Apple Sample project called CoreDataCloudKitShare which is found here:
https://developer.apple.com/documentation/coredata/sharing_core_data_objects_between_icloud_users#
In this sample code there's a "PersistenceController" which is an NSPersistentCloudKitContainer.
In the "PersistenceController+SharingUtilities" file there are some extensions, and one of them is this:
func configure(share: CKShare, with photo: Photo? = nil) {
share[CKShare.SystemFieldKey.title] = "A cool photo"
}
This text "A cool photo" seems to be the only bespoke configuration of the share sheet within this project.
I want to have more options to control the share sheet, does anyone know how this might be achieved? Thank you!
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hello everyone! I've encountered an issue related to SwiftUI and StoreKit. Please take a look at the SwiftUI code snippet below:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
List {
NavigationLink {
Page1()
} label: {
Text("Go to Page 1")
}
}
}
}
}
struct Page1: View {
@Environment(\.dismiss) private var dismiss
@State private var string: String = ""
var body: some View {
List {
NavigationLink {
List {
Page2(string: $string)
.simpleValue(4)
}
} label: {
Text("Tap this button will freeze the app")
}
}
.navigationTitle("Page 1")
}
}
struct Page2: View {
@Binding var string: String?
init(string: Binding<String>) {
self._string = Binding(string)
}
var body: some View {
Text("Page 2")
}
}
extension EnvironmentValues {
@Entry var simpleValue: Int = 3
}
extension View {
func simpleValue(_ value: Int) -> some View {
self.environment(\.simpleValue, value)
}
}
This view runs normally until the following symbol is referenced anywhere in the project:
import StoreKit
extension View {
func notEvenUsed() -> some View {
self.manageSubscriptionsSheet(isPresented: .constant(false))
}
}
It seems that once the project links the View.manageSubscriptionsSheet(isPresented:) method, regardless of whether it's actually used, it causes the above SwiftUI view to freeze.
Steps to Reproduce:
Clone the repository: https://github.com/gongzhang/StrangeFreeze
Open it in Xcode 16 and run on iOS 17-18.1
Navigate to the second page and tap the button, causing the app to freeze.
Remove manageSubscriptionsSheet(...), then everything will work fine
Hello,
I am encountering compatibility issues with older JavaScript frameworks, specifically Ext JS 4.0 and Sencha Touch 2.0, after upgrading to iOS 18.2 Beta. My application, which was working fine on previous versions of iOS, is now experiencing rendering issues, broken touch events, and performance degradation on WebKit in iOS 18.2.
The issues I’m seeing include:
Sencha Touch 2.0: The UI elements (like fields, and lists) are not interactive or showing their content properly. There also seems to be a delay in rendering touch events.
This seem to no longer work as expected with the updated WebKit engine in iOS 18.2 Beta.
My Questions:
Are there any known issues with legacy JavaScript frameworks like Ext JS 4.0 and Sencha Touch 2.0 on iOS 18.2 Beta? Specifically, do these frameworks rely on older DOM methods or JavaScript features that might be deprecated in the latest WebKit engine?
Has Apple officially deprecated any JavaScript features or DOM methods in WebKit that might be causing these issues? If so, are there recommended workarounds or updates to ensure compatibility with iOS 18.2?
Is there a way to enable legacy JavaScript features or fallback modes in iOS 18.2 ?
I would appreciate any guidance on this, as we are facing significant issues with our app’s performance and UI since upgrading to iOS 18.2.
Thank you!
Topic:
UI Frameworks
SubTopic:
General
Hi,
With UIDocumentPickerViewController, there is a directoryURL property that says we can use to 'specify the starting directory for the document picker'. But it's not clear how to get the directory of a folder in iCloud Drive / Files app. How can I get the 'root' directory for a user's iCloud Drive or Dropbox folder, or the Downloads folder on their device, that I could pass to this directoryURL to make it easier for the user to pick their files?
Thanks.
Since iOS 18, I have gotten user reports that the UIDocumentPickerViewController directoryURL is no longer opening the correct folder. Instead it is just loading the root directory of the Files app/iCloud files.
Did something change in iOS 18 that I need to account for? Not all users are having this issue, but some are and they are frustrated because a major feature of my app was to allow users to save files at the ubiquityURL.
I use the following to get the path:
NSURL *rootDirectory = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Photos/%@", folderName]];
Is there something that I need to do differently now in iOS 18 to prevent this from happening?
I'm using UIDocumentPickerViewController to import document to my app from OneDrive and I want to show the OneDrive folder every time I use UIDocumentPickerViewController instead of the last folder I opened. Is it possible? Can I use pickerController.directoryURL ? And how to get folder URL of OneDrive?
class ViewController: UIViewController, DocumentDelegate {
var picker: DocumentPicker?
override func viewDidLoad() {
super.viewDidLoad()
picker = DocumentPicker(presentationController: self, delegate: self)
}
@IBAction func create_picker(_ sender: Any) {
picker?.presentDocumentPicker()
}
func didPickImage(image: UIImage?) {}
}
protocol DocumentDelegate: AnyObject {
func didPickImage(image: UIImage?)
}
class DocumentPicker: NSObject {
private var pickerController: UIDocumentPickerViewController?
private weak var presentationController: UIViewController?
private weak var delegate: DocumentDelegate?
init(presentationController: UIViewController,
delegate: DocumentDelegate) {
super.init()
self.presentationController = presentationController
self.delegate = delegate
}
func presentDocumentPicker() {
pickerController = UIDocumentPickerViewController(forOpeningContentTypes: [.image])
if let pickerController = pickerController {
pickerController.delegate = self
pickerController.allowsMultipleSelection = false
presentationController?.present(pickerController, animated: true)
}
}
}
extension DocumentPicker: UIDocumentPickerDelegate {
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let url = urls.first else { return }
print(url)
}
}
I have a problem if i share photos as uiimage use code "UIImage.makeImage" this code run on iOS 15, 16 normally but if i share on iOS 17,18 to instagram story have error "Something went wrong". This case only error on Instagram story but Instagram post it's normal. Can anyone help me ? is it bug on instagram?
Hello,
I’ve encountered a warning while working with UITableViewDiffableDataSource. Here’s the exact message:
Warning: applying updates in a non-thread confined manner is dangerous and can lead to deadlocks. Please always submit updates either always on the main queue or always off the main queue - view=<UITableView: 0x7fd79192e200; frame = (0 0; 375 667); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600003f3c9f0>; backgroundColor = <UIDynamicProviderColor: 0x60000319bf80; provider = <NSMallocBlock: 0x600003f0ce70>>; layer = <CALayer: 0x6000036e8fa0>; contentOffset: {0, -116}; contentSize: {375, 20}; adjustedContentInset: {116, 0, 49, 0}; dataSource: <TtGC5UIKit29UITableViewDiffableDataSourceOC17ArticleManagement21DiscardItemsViewModel17SectionIdentifierSS: 0x600003228270>>
OS: iOS Version: iOS 17+,
Xcode Version: 16.0,
Frameworks: UIKit, Diffable Data Source,
View: UITableView used with a UITableViewDiffableDataSource.
Steps to Reproduce:
Using a diffable data source with a table view.
Applying snapshot updates in the data source from a main thread.
Warning occurs intermittently during snapshot application.
Expected Behavior:
The snapshot should apply without warnings, provided the updates are on a main thread.
Actual Behavior:
The warning suggests thread safety issues when applying updates on non-thread-confined queues.
Questions:
Is there a recommended best practice to handle apply calls in diffable data sources with thread safety in mind?
Could this lead to potential deadlocks if not addressed?
Note :- I confirm I am always reloading / reconfiguring data source on main thread. Please find the attached screenshots for the reference.
Any guidance or clarification would be greatly appreciated!
Hi community.
I am trying to adopt my first person shooter iOS game for running on MacOS environment.
I need to lock the pointer when I enter battle mode, and unlock in lobby.
On iOS all works fine (with mouse and keyboard) - pointer locks and unlocks according to my commands.
However, on MacOS I faced the following behavior:
after switching the pointer lock state and setNeedsUpdateOfPrefersPointerLocked invocation, the pointer does not locked immediately. To enable pointer lock, the user must click in the window.
I checked the criteria listed in documentation: I do have fullscreen mode, I monitor UISceneActivationState and can confirm it is UISceneActivationStateForegroundActive, I do not use MacCatalyst (it is disabled in app's capabilities). However pointer locks only after click on window, which is weird.
Can someone confirm that this is the exact behaviour as designed by Apple developers, or am I doing anything wrong.
I have read the note:
"Bringing an app built with Mac Catalyst to the foreground doesn’t immediately enable pointer lock. To enable pointer lock, the user must click in the window. To exit pointer lock, users can use Command-tab to switch to another app, or using Command-tilde.", but again, I don't use MacCatalyst.
Any hints are highly appreciated!
Best regards.
refs:
https://developer.apple.com/documentation/apple-silicon/running-your-ios-apps-in-macos
https://developer.apple.com/documentation/uikit/uiviewcontroller/3601235-preferspointerlocked?language=objc