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...
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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?
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?
Creating a context menu via UIContextMenuConfiguration creates the NSMenu as expected on Mac Catalyst but how do I add separator menu items? https://developer.apple.com/documentation/appkit/nsmenuitem/1514838-separatoritem?language=objc
I'm talking about context menus that are shown via right-click, not the menu bar.
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
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.
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.
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?
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
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.
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
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)?
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.
I'm aware signing in to an Apple ID on a macOS Virtual Machine is not supported, unfortunately. But is there a way to download Xcode from within the VM? I know the developer website used to have links where you could directly download Xcode outside the Mac App Store but I can't seem to find it?
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).