Post

Replies

Boosts

Views

Activity

Problems with draggable and dropDestination using DataRepresentation in Transferable
I can't get my drag and drop with DataRepresentation to work with Transferable. I'm trying to drag and drop instances of DataSettings which is an NSManagedObject that conforms to NSSecureCoding. Here's my UTType: extension UTType { static var encoderSettings = UTType(exportedAs: "com.simulator.EncoderSettings") } Here's my conformance to Transferable: extension DataSettings: Transferable { var data: Data? { try? NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: true) } public static var transferRepresentation: some TransferRepresentation { /*DataRepresentation(contentType: .commaSeparatedText) { setting in let data = setting.data print("DataRepresentation: \(data)") return data! } importing: { data in print("data: \(data)") return DataSettings() }*/ DataRepresentation(contentType: .encoderSettings) { setting in let data = setting.data print("DataRepresentation: \(data)") return data! } importing: { data in print("data: \(data)") return DataSettings() } // ProxyRepresentation(exporting: \.title) } } Here's a view where I'm testing my drop destination: struct DropTest: View { @State var isDropTargeted = false var body: some View { Color.pink .frame(width: 200, height: 200) .dropDestination(for: EncoderSettings.self) { setting, location in print("\(setting)") return true } isTargeted: { isDropTargeted = $0 print("Got it!!!") } } } Here's my Info plist: The ProxyRepresentation (String) works but I need the actual Data. The dragging starts (i.e.: I can drag the view that has the .draggable with DataSettings) but I can't drop it on my DropTest view. I can drop it on a view or app that accepts the ProxyRepresentation. What am I missing?
2
0
920
Feb ’23
Disappearing AppIntents
My AppIntents were showing in the Shortcuts app. Now they don't. If I try to create a shortcut my app doesn't show in the list of apps that have shortcuts. I have no compile or linking errors. I'm using Xcode 14.1. My app is UIKit based though it has lots of SwiftUI. Any ideas on how to resolve this would be greatly appreciated.
3
0
1.1k
Nov ’22
Keyboard shortcuts for standard iPadOS 15 keyboard shortcuts
My iPad app supports features such Copy (cmd-C) and Paste (cmd-V). How can I get these to show in the Edit menu when I hold down the Command key? Undo (cmd-Z) and Redo (shift-cmd-Z) show perfectly. Looks like the system internally looks at UndoManager. Same with Hide Sidebar: system detected presence of Sidebar and is showing the keyboard shortcut to hide it. Ramon.
1
0
1k
Jan ’22
Xcode Error trying to subclass UIContextMenuConfiguration
I'm getting Xcode compiler error when trying to subclass UIContextMenuConfiguration. Here's simple code that reproduces the problem: @available(iOS 13.0, *) class DateDifferenceContextMenu: UIContextMenuConfiguration { 		init(indexPath: IndexPath, dateDifference: Int) { 				super.init(identifier: nil, previewProvider: nil, actionProvider: nil) 		} } The error reads: Must call a designated initializer of the superclass 'UIContextMenuConfiguration'. My super call matches the designated initializer. What's wrong?
1
0
734
Sep ’20
How does UIApplication.shared.requestSceneSessionRefresh actually work?
I'm having a hard time understanding how UIApplication.shared.requestSceneSessionRefresh - https://developer.apple.com/documentation/uikit/uiapplication/3197903-requestscenesessionrefresh?language=objc actually works. According to the documentation, this is used to update scenes that are in background. But does the API call something in your background scene to allow the UI to update or is it assumed that you've updated your background scene and this call will just capture your UI? Please clarify.
0
0
618
Jun ’20
NSUserActivity missing userInfo for a newly requested scene
I'm creating a new scene like: UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil/*options*/) { error in       dPrint("\(error)")     } The activity parameter has userInfo that I need in the new scene; for example,     activity.userInfo = ["sampleKey":"sampleData"] Here's how I'm creating the new scene:   func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {         guard let windowScene = scene as? UIWindowScene else { return }     window = UIWindow(windowScene: windowScene)     window?.rootViewController = ContainerViewController(to: createSplitViewController())     window?.makeKeyAndVisible()     scene.title = SystemData.appName     if appDelegate.isOnboardingNeeded, let containerController = window?.rootViewController as? ContainerViewController {       appDelegate.launchOnboardingIfNeeded(with: containerController)     }     if let activity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {       dPrint("\(#function) \(activity)")       masterViewController?.restore(from: activity, isStandalone: false, persistentId: scene.session.persistentIdentifier)     }   } The print statement has an empty userInfo. What's the problem?
3
0
1.4k
Jun ’20
viewcontroller lifecycle in UIWindowSceneDelegate
I've made the architectural changes following best practices to support multiple windows in map. In general, it seems to be working fine except for one general thing. It seems that some the view controller life cycle methods (i.e.: viewWillDisappear, viewDidDisappear) never get called. I realize you can accomplish all that these methods do with the proper delegates in UIWindowSceneDelegate but its not clear to me that this is the way it's supposed to be.In the documentation it's clear that many methods in AppDelegate lifecycle are now replaced by their corresponding UIWindowSceneDelegate methods but I haven't found anything that indicates view controller life cycle.It seems that the initial methods are still called (i.e.: viewWillAppear, viewDidAppear) but not trailing methods (i.e.: viewWillDisappear, viewDidDisappear).Is that how it's suppose to work or am I doing something wrong?Thanks!
7
0
3k
Jun ’20
Problems with UIScene and ViewController
I've modified my app to create new windows using App Exposé or by dragging out of the dock. But it seems as if my viewcontroller and scene get out of sync. I've verified this by printing the unique persistentIdentifier that comes with every scene session. I'm using storyboards so my scene delegate is rather simple.@available(iOS 13.0, *) class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { let rootVC = self.window?.rootViewController dPrint("\(#function) rootVC \(String(describing: rootVC!)) pId \((scene as? UIWindowScene)?.session.persistentIde}ntifier ?? "??" )") } }Here's my info.plist<key>UIMainStoryboardFile</key> <string>Main</string> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <true/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> <key>UISceneStoryboardFile</key> <string>Main</string> </dict> </array> </dict> </dict>And AppDelegate: func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Based on the name of the configuration iOS will initialize the correct SceneDelegate return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) }I delete the app from the simulator to start with a clean scenerio. I open the app and the initial scene gets created. I print its persistentIdentifier and its: 67926371-9D25-46DC-BD52-8D44B1967B33. I use the a bit and the corresponding persistentIdentifier shows. All good!Now, I go to the home screen, show all windows (only one shows) and select the plus button on the upper right corner to create another scene/window. The new scene gets created and it gets it's own persistentIdentifier: B73F438D-942F-435C-87E7-117BF6E06C79.I use the app and the corresponding persistentIdentifier (for newly created scene) shows. Now I go to the home screen, show all windows and I select the originally created scene. But now the persistentIdentifier shown is still the one for the secodd scene! After creating the second scene, my UI always shows the persistentIdentifier for the second scene regardless of whih scene is in the foreground.This is actually the second app I'm adding multi-window support. So, I have some experience doing this. The first app was similar: storyboard based, etc. It works perfectly. I've verified that the persistentIdentifier is suppoed to follow the viewcontroller.It appears as if the scene and view controllers are out of sync. Why is this happening? What am I missing?
0
0
1.9k
Mar ’20