With iPadOS26, if I create a UITabBar, and use that to switch between views, the selected state never updates. I created this simple UIViewController to demonstrate the issue:
class SimpleTabBarController: UIViewController, UITabBarDelegate {
let tabBar = UITabBar()
let redItem = UITabBarItem(title: "Red", image: nil, tag: 0)
let blueItem = UITabBarItem(title: "Blue", image: nil, tag: 1)
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
tabBar.items = [redItem, blueItem]
tabBar.selectedItem = redItem
tabBar.delegate = self
tabBar.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tabBar)
NSLayoutConstraint.activate([
tabBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
tabBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tabBar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
])
updateBackground(for: redItem)
}
func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
updateBackground(for: item)
}
private func updateBackground(for item: UITabBarItem) {
switch item.tag {
case 0: view.backgroundColor = .systemRed
case 1: view.backgroundColor = .systemBlue
default: view.backgroundColor = .white
}
}
}
The tabBar didSelect item method is called, and the background color gets updated as expected, but the selected state of the UITabBar stays the same.
I files a feedback for a related issue: FB17841678
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
I have an app that uses Core Data to store user information and display it in various views. I want to know if it's possible to easily integrate this setup with FoundationModels to make it easier for the user to query and manipulate the information, and if so, how would I go about it? Can the model be pointed to the database schema file and the SQLite file sitting in the user's app group container to parse out the information needed? And/or should the NSManagedObjects be made @Generable for better output? Any guidance about this would be useful.
Hi,
I am testing a situation with shared CKRecords where the data in the CKRecord syncs fine, but the creatorUserRecordID.recordName and lastModifiedUserRecordID.recordName shows "defaultOwner" (which maps to the CKCurrentUserDefaultName constant) even though I made sure I edit the CKRecord value from a different iCloud account. In fact, on the CloudKit dashboard, it shows the correct user recordIDs in the metadata for the 'Created' and 'Modified' fields, but not in the CKRecord.
I am mostly testing this on the iPhone simulator with the debugger attached. Is that a possible reason for this, or is there some other reason the lastModifiedUserRecordID is showing the value for 'CKCurrentUserDefaultName'? It would be pretty difficult to build in functionality to look up changes by a different userID if this is the case.
I'm using the #Playground macro in Xcode 26.0, running on macOS 26.0. I can get the basics working, but I don't understand how it hooks into the rest of the app, like the App Delete or the Core Data stack. Do we have to create a new Core Data stack, like for SwiftUI Previews, or can it hook into the stack from the main app (if so, how)?
In my UIKit app, in my view controller, I have a toolbar at the bottom of the screen and a UITextView, and I need to get the size of the toolbar to calculate the correct keyboard intersection, and change my text view layout so that the text doesn't get obscured when the keyboard is shown on screen. It's been working fine till now, but with iOS26, I am running into an issue, because the toolbar size is completely different.
For this code:
NSInteger offset = (self.navigationController.isToolbarHidden == NO)? (self.navigationController.toolbar.frame.size.height): 0;
iOS18 returns '49'
iOS26 returns ''812'.
This obviously throws off the calculations for keyboard avoidance.
Is there a way to overcome this, other than ignoring or hard-coding toolbar height?
Topic:
UI Frameworks
SubTopic:
UIKit
Hi,
I have an NSOutlineView, and each cell within that has an NSCollectionView (a horizontal one), setup using autolayout with the 'height' of the collectionView driving the height of the OutlineView cell. Each item in the collectionView can have a dynamic width, and I use a 'dummy' collectionView to size each item from it's contents, then getting the height of the collectionView and using a 'height constraint' to make each collectionView get the height it needs (and hence the cell have a dynamic height.
It works fine for the most part, but I get this warning multiple times in the console:
"The behavior of the UICollectionViewFlowLayout is not defined because: the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
The relevant UICollectionViewFlowLayout instance is <NSCollectionViewFlowLayout: 0x10e3b7f80>, and it is attached to <MacTagsCustomCollectionView: 0x10e3b7840>.
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger."
I've tried Googling this, but I can't find a good explanation for this issue. Also, I'm not sure why it references 'UICollectionViewFlowLayout' when it's an AppKit app and uses NSCollectionView. Also, setting the 'UICollectionViewFlowLayoutBreakForInvalidSizes' symbolic breakpoint doesn't help since it never gets triggered.
Here is some code from my outlineView's viewForTableColumn, where I get the height of the collectionView and hence the height of the cell:
result = [outlineView makeViewWithIdentifier:@"DataWithTags" owner:self];
if (result.tagListCollectionView.delegate == nil) {
result.tagListCollectionView.delegate = self;
result.tagListCollectionView.dataSource = self;
result.tagsCollectionViewScrollView.automaticallyAdjustsContentInsets = NO;
result.tagListCollectionView
NSNib *cellNib = [[NSNib alloc] initWithNibNamed:@"MacTagsForPersonItem" bundle:nil];
[result.tagListCollectionView registerNib: cellNib forItemWithIdentifier:@"PersonTagsCollectionViewItemID"];
if (self.tagsSizingItem == nil) {
NSArray *topLevelObjects;
[cellNib instantiateWithOwner:self.tagsSizingItem topLevelObjects: &topLevelObjects];
for (id topLevelObject in topLevelObjects) {
if ([topLevelObject isKindOfClass:[MacPersonTagsCollectionViewItem class]]) {
self.tagsSizingItem = topLevelObject;
break;
}
}
}
result.tagListCollectionView.backgroundColors = @[[NSColor clearColor]];
result.tagListCollectionView.enclosingScrollView.backgroundColor = [NSColor clearColor];
result.tagsCollectionViewScrollView.verticalScroller.hidden = YES;
}
result.tagListCollectionView.tagsPerson = person;
[result.tagListCollectionView reloadData];
result.frame = outlineView.bounds;
[result layoutSubtreeIfNeeded];
[result.tagListCollectionView layoutSubtreeIfNeeded];
if (person.tagsCacheHeight == 0) {
	 person.tagsCacheHeight = result.tagListCollectionView.collectionViewLayout.collectionViewContentSize.height;
}
result.collectionViewHeightConstraint.constant = person.tagsCacheHeight;
Anyone with any idea on how to overcome this? I feel that it's responsible for some layout issues that I'm having in the view.
I want to add a NSDatePicker in the sidebar of my app, to help select a date , or a range of dates. I could use the standard NSDatePicker, but it only seems to come in a single size, and doesn't seem to be resizable. I've dropped the NSDatePicker component into a xib file, and added auto-layout constraints, but they don't seem to work. Is there a way to make them respond to auto-layout and be resizable? Or should I be looking for 3rd-party frameworks to integrate with (if so, any recommendations)?
Hi,
In my Core Data schema, I have a 'transformable' attribute in an entity, which is using a custom NSValueTransformer, the purpose of which is to convert a UIImage into NSData with some compression (basically to save a small thumbnail from the image). From this attribute, I had recently started getting these warnings about using NSKeyedUnarchiveFromData:
'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
So I read about this, and figured I'd need to change the NSValueTransformer to using NSSecureUnarchiveFromDataTransformer ... but after making the changes (as best as I understood them) I can't get it to work, and now the app crashes when the attribute is accessed.
This is the existing NSValueTransformer that I was using:
@interface ImageToDataTransformer : NSValueTransformer {
}
@implementation ImageToDataTransformer (BOOL)allowsReverseTransformation {
return YES;
}
(Class)transformedValueClass {
return [NSData class];
}
(id)transformedValue:(id)value {
// for our smaller views this uses much less data and makes for faster syncing
NSData *compressedData = UIImageJPEGRepresentation(value, 0.2);
return compressedData;
}
(id)reverseTransformedValue:(id)value {
UIImage *uiImage = [[UIImage alloc] initWithData:value];
NSData *data = (NSData *) value;
//NSLog(@"reverseTransformedValue: image size: %@", [NSByteCountFormatter stringFromByteCount:data.length countStyle:NSByteCountFormatterCountStyleFile]);
return uiImage;
}
So I changed it to subclass from NSSecureUnarchiveFromDataTransformer instead, and added the following to the implementation:
(NSArrayClass *)allowedTopLevelClasses {
return @[[ImageToDataTransformer class]];
}
(void)setValueTransformer:(nullable NSValueTransformer *)transformer forName:(NSValueTransformerName)name {
NSLog(@"ImageToDataTransfer: calling setValueTransformer");
[NSValueTransformer setValueTransformer:transformer forName:name];
}
(NSArrayNSValueTransformerName *)valueTransformerNames {
return @[@"ImageToDataTransformerName"];
}
Before the Core Data persistent store is accessed, I 'register' the transformer:
[ImageToDataTransformer setValueTransformer: [[ImageToDataTransformer alloc] init] forName:@"ImageToDataTransformerName"];
Now the app crashes when the image is read:
[__NSCFData _rasterizedImage]: unrecognized selector sent to instance 0x7ff53c108800
If I change the transformer back to NSValueTransformer, it works fine. So I'm not sure if I'm missing something from the implementation, or I have misunderstood the premise of 'NSSecureUnarchiveFromDataTransformer'. Would love to know what I can do to fix this.
Hi,
I've been working with Core Data for a number of years, and I remember that when I needed to add attributes or entities to the data model, I had to first create a new model version, then add the new attributes/entities, and then use the "lightweight migration' flag when adding the NSPersistentStore to the NSPersistentStoreCoordinator. If it didn't add the new model version, the app would crash.
I've tried adding something to my data model now after a few years, without adding a new model version in Xcode. And right now, it seems to work fine. I can read/write to the new attribute that I added to an entity, and nothing crashed. I tried this on the simulator, as well as on my device.
Did something change at some point, where adding a new model version isn't a requirement for using lightweight migration? Or am I missing something? Why isn't it crashing anymore (and will it crash if I change my model without adding a new model version and ship it to production)?
Thanks.
I am adding a small SwiftUI view to my NSTableViewCell, using NSHostingView. Occasionally (randomly) I get this crash in the debugger, but I don't understand what it means:
#0 0x00007fff4309ace6 in AG::data::table::grow_region() ()
#1 0x00007fff4309b155 in AG::data::table::alloc_page(AG::data::zone&, unsigned int) ()
#2 0x00007fff4309b430 in AG::data::zone::alloc_slow(unsigned int, unsigned int) ()
#3 0x00007fff430a1bad in AG::Graph::add_attribute(AG::Subgraph&, unsigned int, void const*, void const*) ()
#4 0x00007fff430b87fe in Attribute.initτ_0_0(body:value:flags:update:) ()
#5 0x00007fff42e8da29 in GraphHost.Data.init() ()
#6 0x00007fff4273e532 in ViewGraph.initτ_0_0(rootViewType:requestedOutputs:) ()
#7 0x00007fff4273e3be in ViewGraph.__allocating_initτ_0_0(rootViewType:requestedOutputs:) ()
#8 0x00007fff42d795d6 in NSHostingView.init(rootView:) ()
#9 0x00007fff42d785dd in NSHostingView.__allocating_init(rootView:) ()
#10 0x00000001036494ff in ContactsCountIconsInterface.makeContactsCountView() at /Users/z/Documents/Git/branches/SimpleList/Mac/ContactsCountIconsInterface.swift:23
#11 0x0000000103649558 in @objc ContactsCountIconsInterface.makeContactsCountView() ()
#12 0x000000010347ed1a in -[ContactDataCellView setupIconsCountViewWithCountForLogsCount:todosCount:filesCount:] at /Users/z/Documents/ContactsJournalGit/branches/SimpleList/ContactDataCellView.m:40
#13 0x0000000103445f88 in -[MacContactsViewController outlineView:viewForTableColumn:item:] at /Users/z/Documents/ContactsJournalGit/branches/SimpleList/Mac/MacContactsViewController.m:745
#14 0x00007fff22dde8b5 in -[NSTableView(NSTableViewViewBased) makeViewForTableColumn:row:] ()
#15 0x00007fff22dddf03 in -[NSTableRowData _addViewToRowView:atColumn:row:] ()
#16 0x00007fff22dddc38 in -[NSTableRowData _addViewsToRowView:atRow:] ()
#17 0x00007fff22ddbf41 in -[NSTableRowData _initializeRowView:atRow:] ()
#18 0x00007fff22dda3d3 in -[NSTableRowData _preparedRowViewForRow:storageHandler:] ()
#19 0x00007fff22dda21e in -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] ()
#20 0x00007fff22dda034 in -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] ()
#21 0x00007fff22dd8f2a in -[NSTableRowData _updateVisibleRowEntries] ()
#22 0x00007fff236dedbb in __59-[NSTableRowData _automaticRowHeightsUpdateVisibleRowViews]_block_invoke.1371 ()
#23 0x00007fff22fff21b in -[NSTableRowData _keepTopRowStable:andDoWorkUntilDone:] ()
#24 0x00007fff22ffeff8 in -[NSTableRowData _automaticRowHeightsUpdateVisibleRowViews] ()
#25 0x00007fff22dd8873 in -[NSTableRowData updateVisibleRowViews] ()
#26 0x00007fff22f089da in -[NSTableRowData prepareContentInRect:] ()
#27 0x00007fff22f0896f in -[NSTableView prepareContentInRect:] ()
#28 0x00007fff22f086d6 in __38-[NSView _pullInExtraTilesForOverdraw]_block_invoke ()
#29 0x00007fff22f07fd2 in -[NSView _performWorkOnTilesFromRect:renderedContentRect:maximumRect:scrollVelocity:handler:] ()
#30 0x00007fff22f07767 in -[NSView _pullInExtraTilesForOverdraw] ()
#31 0x00007fff22f073ef in -[NSView _doIdlePrefetch] ()
Can anyone comment on how to decipher this crash?
Hi,
I am using the (deprecated) UILocalNotification class in my app right now, because it fulfills a need that the UserNotification framework doesn't fulfill even 5 years after it was introduced. In my app, users can setup 'reminders' for different tasks, and those could be one-off tasks, or repeating tasks that start from a particular date/time. The UserNotifications system doesn't work with the latter requirement; it doesn't allow for you to setup a repeating alert which starts at a specific date/time. You can either setup a one-off alert in the future, or you can setup a repeating alert which starts as soon you set it up. As an example, I want to be reminded to call a friend of mine every week, from July 10th onward ... with the UserNotification framework, setting a 'repeat' will mean it'll fire an alert every week, starting from today.
So what's the best way to build a solution to this? Is there a way to 'intercept' the alert before it's shown (if it's before the date we want it to start firing)? Should I be looking at some 3rd-party services to do this remotely?
Thanks!
Hi,
I want to install macOS Catalina on a partition on my computer's hard drive to test and fix some bugs for my Mac app. I can't seem to find a simple way to download the installer. I found a link to the Catalina page on the Mac App Store through some other website, but when I try to download it, I get an error saying "This copy of the macOS Catalina installer application is too old to be opened on this version of macOS".
I've checked the Downloads page from the developer page, and it's not listed there either. What gives? Shouldn't be easier to test Mac apps on older versions?
FWIW I'm trying this on a MacBook Pro 2016.
Hi,
I haven't been able to add some basic SiriKit actions to my macOS app in macOS Monterey. To test this out, I created a new project, made it a macOS app with Storyboard. Then I added an intents definition file, and added a basic intent, with no inputs/outputs. I added the intent name to "Supported Intents" in the target "General" configuration.
Now when I build and run the app, the shortcut doesn't show up in the Apple Shortcuts app. I've tried looking for the "Siri" capability in "Signing & Capabilities" and it's not listed there (compared to a new iOS app where it would be).
I'm not sure what I'm missing here. Would love some help.
I'm using Xcode 13.1 on macOS Monterey RC.
I am building a widget for my (AppKit) Mac app, and one thing I can't figure out is how to detect when a Link is pressed in the widget to open the parent app. It just opens the parent app but I can't get any information about the URL that was passed in. With iOS, it's easy to detect, from the AppDelegate method:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
I can't find anything equivalent on macOS. Can someone point me to the right place?
Hi,
I have an existing AppKit-based Mac app that I have been working on for a few years. For a new feature, I wanted to have the app opened by a different app, so I setup the URL scheme under CFBundleURLTypes in my Info.plist, and adopted this delegate callback:
- (void)application: (NSApplication *)application openURLs:(nonnull NSArray<NSURL *> *)urls
Now when I invoke the URL from the 2nd app, it opens my app correctly, BUT this delegate method isn't called. What's interesting is that if I make a totally new app with a URL scheme and adopt this delegate method, it gets called without a problem!
SO what about my original project could be responsible for this 'opensURLs' method to not be called? I've been searching for a solution for a couple of days without any luck. The macOS app's target has a Deployment Target of 10.15 and I'm running this on macOS12.0 with Xcode 13.