Posts

Post not yet marked as solved
4 Replies
1.6k Views
Hi, I have Mac catalyst app, that usually shows one window, but under some circumstances I open another one with different content (so it is multi-windowed app, but not in a way of opening several documents in instances of the same type of window). I did manage to setup SceneDelegate, open scenes etc., but I have still some problems. After app launch, old scenes are automatically recreated. Is there a way to stop it? I want to always start with main scene, and only open the second one from code. Is there a way to set size and position of a window before it is shown? I can do it by acquiring NSWindow from UIWindow and then using AppKit from another bundle. But this can only be done after the window appears on screen. As a result, user sees window "jump". When scene is being created (or maybe just recreated to restore previous session), window gets the same position it had before. Is there any way to control it? How this mechanism exactly works? Where are the previous positions stored and can they be modified? How a newly created scene gets its size and position?
Posted
by Kaven.
Last updated
.
Post not yet marked as solved
0 Replies
383 Views
On MacOS (catalyst app, but AppKit bundle) I am creating Share submenu in main app menu "on fly" from menu delegate like this: func menuWillOpen(_ menu: NSMenu) { self.provider = NSItemProvider(contentsOf: url)! //url points to existing temporary file of type .png menu.removeAllItems() let srvcs = NSSharingService.sharingServices(forItems: [self.provider!]) for srv in srvcs { let it = NSMenuItem(title: srv.menuItemTitle, action: #selector(openSharingService), keyEquivalent: "") it.image = srv.image it.representedObject = srv it.target = self menu.addItem(it) } } @objc private func openSharingService(sender: NSMenuItem) { let service = (sender.representedObject as! NSSharingService) service.perform(withItems: [self.provider!]) } It works well for any share type, except for Send To Photos. With Send To Photos, I am getting this error in console: > 2021-10-27 08:59:02.042220+0200 Calculator2[14383:7732689] [xpc.exceptions] <NSXPCConnection: 0x6000008470c0> connection to service on pid 14388 named com.apple.share.System.add-to-iphoto.apple-extension-service: Exception caught during decoding of received selector _completeRequestReturningItems:forExtensionContextWithUUID:completion:, dropping incoming message. Exception: Exception while decoding argument 0 (#2 of invocation): Exception: value for key 'NS.objects' was of unexpected class 'NSURL (0x7fff801889e8) [/System/Library/Frameworks/CoreFoundation.framework]'. Allowed classes are '{( "NSDate (0x7fff80188600) [/System/Library/Frameworks/CoreFoundation.framework]", "NSString (0x7fff801ba8d0) [/System/Library/Frameworks/Foundation.framework]", "NSNumber (0x7fff801ba3a8) [/System/Library/Frameworks/Foundation.framework]", "NSData (0x7fff801885d8) [/System/Library/Frameworks/CoreFoundation.framework]", "NSDictionary (0x7fff80188650) [/System/Library/Frameworks/CoreFoundation.framework]", "NSArray (0x7fff80188510) [/System/Library/Frameworks/CoreFoundation.framework]" )}'. Photos app is opened and image is added to it, but my app recieves the above error and its menus are all grayed out until restarted. Am I doing something wrong here?
Posted
by Kaven.
Last updated
.
Post not yet marked as solved
0 Replies
646 Views
I have an app for ipad/iphone, now adding also mac support by Mac Catalyst. On Mac, I want to control window resizing, in order to allow only some sizes and aspects. It goes beyond simple minimal height and weight, or aspect. I want to allow user to resize window freely, but when it gets too high and narrow, I want to also seemlessly increase width, to keep some minimal aspect. I believe that in AppKit it can be done through NSWindowDelegate.windowWillResize() (get user defined size, count required size and return it). However I am getting error "NSWindowDelegate is unavailable in Mac Catalyst" . Is it possible to achieve the result I want by Catalyst means?
Posted
by Kaven.
Last updated
.