Post

Replies

Boosts

Views

Activity

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
789
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
694
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
814
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
826
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
681
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
483
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
796
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
804
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
567
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
Programmatically Launch an macOS Action Extension?
Is there a way to programmatically launch a macOS Action Extension (related documentation: https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/Action.html) I'm aware how to create "Action Extensions" but they only seem to be activated from NSTextView "rollover" button. Say I know there is an action extension that works on a particular type of data can I launch it from my app? Obviously we can launch "regular" apps with NSWorkspace by bundle iD but I was wondering if there is any API where my app could directly launch an action extension as the "host app" programmatically.
1
0
767
Oct ’23
Is the Hardened Runtime required for Mac Apps Now?
I just tried submitting an app to be notarized. This app is actually only used by me internally (but I have other apps this question would be relevant to) and I can't submit for notarization. I get the following error: "Hardened Runtime is not enabled." Is the Hardened Runtime now required? I know it used to be optional (I believe the last time I submitted an app update a few months ago outside the Mac App Store I got no such error).
6
0
1.5k
Feb ’24