Post

Replies

Boosts

Views

Activity

Is it possible to use Settings.bundle just for Mac Catalyst, and not for the iOS version of the app?
I was wondering if it was possible to use a Settings.bundle just for the Mac Catalyst version of the app? On the iOS version I handle my preferences in app as it is easier to sync with iCloud key value storage, plus doing it in-app has the added convenience of not making the user navigate to the Settings app to manage preferences. On Mac Catalyst however using a Settings.bundle would be nice because I'd get UI for free and the user doesn't have to navigate to a different app to manage preferences. Also I have a few preferences that only apply to the iOS version of the app, and some that only apply to the Mac version of the app (preferences that don't apply to the platform the app is running on should be excluded from the UI). So is there a way to specify a Settings.bundle just for Mac Catalyst? If not, is there a way to specify that a particular preference is "Mac Only" in the plist files inside the Settings bundle?
1
0
1k
Jan ’23
UICollectionView List Style on Mac Catalyst: Prevent the Collection View From Changing the Selection when the Selected Row's Parent is Collapsed?
I'm using UICollectionView with a list style on Mac (looks like NSOutlineView in a sidebar). I have expandable rows. So this is the behavior I'm after: -If the user has a row selected, but decides to collapse the selected row's parent, I want to maintain the current selection. Instead this is what happens by default: -If a row selected and I collapse the parent the collection, the collection view automatically selects another row (in my case the first row at index path 0-0). Just because the user collapses the parent doesn't mean the selection should change. For instance in Xcode's Navigator I can have a file selected in a Group and collapse the group without modifying the current selection.
2
0
632
Oct ’22
Update title of NSMenuItem in Menu Bar on Mac Catalyst Based on Current Context?
I'm using UIMenuBuilder API to add a menu item to the menu bar on Mac Catalyst (adding a UIKeyCommand object). So depending on the current selection the title of the menu item should change. As an example in Finder if a single file is selected and you go to the "Edit" menu in the menu bar there is an item that says "Copy Filename" Now select two files in Finder and go to Edit menu in the menu bar and now it says "Copy 2 Items" Updating a NSMenuItem in Appkit is pretty easy. I figured I'd be able to do this in -canPerformAction:withSender: but the system doesn't pass my UIKeyCommand as the sender but instead an instance of a private class _UIMenuBarItem. I assume there must be a way to dynamically update the title of a menu bar item in a Catalyst app?
1
0
987
Nov ’22
NSUndoManager -setActionName: being ignored on Mac Catalyst
So I just noticed that my calls to -setActionName: on NSUndoManager are not properly updating the Undo/Redo menu item titles in the menu bar on Mac Catalyst. At first I thought maybe my actionName string was too long, so I just created a really simple sample project and ...yeah...my calls to -setActionName are ignored. The menu bar items just say "Undo" and "Redo.." Sample: -(IBAction)changeBackgroundColorAction:(UIButton*)sender {     UIColor *currentBGColor = self.view.backgroundColor;     self.view.backgroundColor = UIColor.yellowColor;     NSUndoManager *undoManager = self.undoManager;     [undoManager registerUndoWithTarget:self selector:@selector(setBackgroundColorWithColor:) object:currentBGColor];     [undoManager setActionName:@"Change BG Color"]; } I'm really starting to regret not using AppKit...
4
0
805
Nov ’22
How does UNNotificationResponse determine targetScene if app specifies multiple Scene Configurations?
I use UNUserNotificationCenterDelegate. I'm in the process of adding new scene configurations for windows for the Mac environment. Some of these windows are auxiliary windows. So I was just wondering what happens with UNNotificationResponse targetScene property. In -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: is it possible for one of the auxiliary window scenes to be the targetScene or does UNNotificationResponse always choose the configuration at index 0 in the info.plist?
1
0
703
Feb ’23
Mac Catalyst Make Text in UICollectionViewCell configured with UIListContentConfiguration selectable with mouse/trackpad?
I have a UICollectionView in the list style. I have cells that use   UIListContentConfiguration. All this is set up in the normal way: UIListContentConfiguration *contentConfig = cell.defaultContentConfiguration;   contentConfig.text = @"Bla text"; cell.contentConfiguration = contentConfig; But I can't figure out how to make the text selectable on Mac Catalyst with the mouse? On iOS this is okay (though selectable text would be nice there too) but on Mac users would really expect the text to be selectable in this area of my app's UI. Is there anyway to configure this?
3
0
828
Dec ’22
Sharing Multiple Links at Once on Mac Catalyst Via UIActivityViewController for the Messages Activity?
Is it possible to share multiple links at once on Mac Catalyst to Messages? When I provide multiple urls via the UIActivityItemSource API Messages just picks 1 of the links. The Mail activity handles multiple links without a problem but I'd like this to work with Messages too. I know for sure this is possible in native AppKit but can't seem to figure out how to get this to work on Catalyst. I tried providing the links to UIActivityViewController with a UIActivityItemsConfiguration object instead of using the UIActivityItemSource API but that didn't work either. Thanks in advance
1
0
839
Dec ’22
Mac Catalyst Determine Default Size of NSToolbarItems When Creating them with UIBarButtonItems and SF Symbol Images?
Is there a way to programmatically determine the default size of an NSToolbarItem when creating them on Mac Catalyst like so:  UIImage *downArrowImage = [UIImage systemImageNamed:@"arrow.down"]; UIBarButtonItem *goDownUIBarButtonItem = [[UIBarButtonItem alloc]initWithImage:downArrowImage style:UIBarButtonItemStylePlain target:nil action:@selector(navigateDownard:)];  NSToolbarItem *nsToolbarItem = [NSToolbarItem itemWithItemIdentifier:itemIdentifier barButtonItem:goDownUIBarButtonItem]; Why am I asking? I need to create a toggle toolbar item (which requires me to change the toolbar item's image when the toggle is flipped. I can do this by using NSUIViewToolbarItem and embedding a UIButton. But when you feed an SF Symbol image to UIButton and call sizeToFit on it it doesn't generate a view that matches the size of UIBarButtonItems for all the other NSToolbarItems next to it. I can hard code size constraints in like this to make it size properly:  NSLayoutConstraint *width = [theUIButtonToEmbedInToolbarItem.widthAnchor constraintEqualToConstant:32.0];     NSLayoutConstraint *height = [theUIButtonToEmbedInToolbarItem.heightAnchor constraintEqualToConstant:32.0]; //activate these constraints and embed the UIButton in the NSToolbarItem. And that's works but I'm guessing the size so the layout could break in a OS update. I tried just feeding an SF Symbol image to NSToolbarItem's image property directly but then the toolbar item doesn't draw at all (edit: this is only true when using an NSToolbarItem subclass, which I created to change the toolbar item's image itself when the toggle property is flipped) //Inside my NSToolbarItem subclass. -(void)setOn:(BOOL)isOn { if (_on != on) { _on = isOn; self.image = (isOn) ? self.onImage : self.offImage; } } So when using NSToolbaritem's image property directly setting the image property works fine, this means I have to track the toggle state externally which is possible but definitely not as nice). Edit: Actually if forgot to modify my toolbar item subclass to subclass NSToolbarItem directly (was subclassing NSUIViewToolbarItem when I was first experimenting with using UIButton). Using the image property on NSToolbarItem directly works for me. So I'm happy. I still think it'd be useful for clients that need to embed custom views inside a NSToolbarItem to get some kind of size recommendation.
1
0
691
Dec ’22
Enable WKWebView Web Inspector Under Mac Catalyst?
I'm trying to enable the web inspector on WKWebView in a Mac Catalyst app. I'm only doing this for debugging purposes. In the released the web inspector will not be enabled. Doing this under Mac Catalyst does not work:  WKPreferences *prefs = [[WKPreferences alloc]init];   [prefs _setDeveloperExtrasEnabled:YES]; //Assign the WKPreferences to a WKWebViewConfiguration and create the web view.. Is there any way to do this? Thanks in advance.
4
0
1.8k
Oct ’23
UISheetPresentationController Get the Grabber Height?
I'd like to ensure certain content doesn't overlap UISheetPresentationController's grabber. In the view controller subclass that is being presented as a sheet via UISheetPresentationController I tried inspecting self.view.safeAreaInset.top hoping that this would account for the UISheetPresentationController's grabber but safeAreaInset.top is 0 unfortunately. Right now I'm just using a hard coded value but is there API for this I overlooked?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
493
May ’23
Enable User Interaction on the Presenting View Controller when using a custom UIPresentationController
I'm using a custom UIPresentationController. I'd like the replicate the behavior of UISheetPresentationController and allow user interaction the presenting view controller when the presented view controller does not cover the entire screen. I tried this: -(void)presentationTransitionDidEnd:(BOOL)completed { UIView *theView = self.presentingViewController.view; theView.userInteractionEnabled = YES; } But has no effect. Is it possible to achieve this behavior? Thanks in advance
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
805
May ’23
WKContentRuleList JSON file documentation? "trigger" vs "condition"?
I'm having a hard time finding samples that clearly explain how to use WKContentRuleList objects. I read that WKContentRuleList use the same format as Safari content blocker extensions however when I try to compile a content blocker from the sample app AdoptingDeclarativeContentBlockingInSafariWebExtensions it complains about missing a "trigger". I get Error Domain=WKErrorDomain Code=6 "(null)" UserInfo={NSHelpAnchor=Rule list compilation failed: Invalid trigger object.} When I try to use the rules from the AdoptingDeclarativeContentBlockingInSafariWebExtensions sample project: [ { "id": 1, "priority": 1, "action": { "type": "block" }, "condition": {"regexFilter": ".*", "resourceTypes": [ "image" ] } }, { "id": 2, "priority": 1, "action": { "type": "allow" }, "condition": {"regexFilter": "wikipedia", "resourceTypes": [ "image" ] } } ] So if WKContentRuleList requires different keys/value pairs than Safari content blockers are those differences documented anywhere? I can't really find any good info on this. Thanks in advance.
Topic: Safari & Web SubTopic: General Tags:
2
0
817
Jun ’23
WKContentRuleListStore fails to compile "Too many rules in JSON array" What's the max?
When trying to compile a rule list via WKContentRuleListStore's -compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler: method I'm getting the following error: ** Rule list compilation failed Too many rules in JSON array.** The max number of rules allowed in a WKContentRuleList doesn't seem to be documented (or I couldn't find it). Does anyone know what the limit is? Thanks
Topic: Safari & Web SubTopic: General Tags:
1
0
580
Jul ’23
UIKit Live Preview for Objective-C View Controller?
Now that live previews are available in UIKit (source: https://developer.apple.com/wwdc23/10252) I was wondering how to get a UIViewController from Objective-C. The Swift macro looks like this: #Preview { var controller = SomeViewController() return controller; } Is there a way to get a live preview for UIViewControllers/UIViews written in Objective-C (other than wrapping it as a child view controller in an empty swift view controller)?
4
0
1.4k
Sep ’23