iOS 16 UITableView: You are setting a new content configuration to a cell that has an existing content configuration, but the existing content view does not support the new configuration. Existing content configuration is nil.

I’m trying to migrate a custom UITableViewCell to use a content configuration so I can properly subclass the content view (setting a subclass on the content view in Interface Builder apparently is not supported).

So when I load up the cell and set the content configuration my console is flooded with these logs:

Warning: You are setting a new content configuration to a cell that has an existing content configuration, but the existing content view does not support the new configuration. This means the existing content view must be replaced with a new content view created from the new configuration, instead of updating the existing content view directly, which is expensive. Use separate reuse identifiers for different types of cells to avoid this. Make a symbolic breakpoint at UIContentConfigurationAlertForReplacedContentView to catch this in the debugger.

Cell: <MyCellSubclassHere: 0x15d0b5c00> Existing content configuration: (null); New content configuration: <MyCustomConfigurationHere: 0x6000034ad190>


As you can see the existing content configuration is nil. I tried setting my custom content configuration as early as possible (by overriding the designated initializer on UITableViewCell) as a workaround but that didn't work. Still console spew.

And by the time cellForRowAtindexPath: is called the content configuration is always nil and has to be rebuilt (apparently UIKit is setting it to nil in prepareForReuse?)

I also tried overriding -setContentConfiguration: to catch when the configuration is being set to nil but UIKit must be setting the ivar to nil directly, because the setter is never called with nil.

Anyone know of a workaround? I don't want to ship an app that constantly logs this out on scroll.

I opened FB11595949

Aha. The problem was I forgot to assign the configuration property on the content view! 🤦‍♂️

-(nonnull __kindof UIView<UIContentView>*)makeContentView

{
    CustomContentView *customContentView = [[CustomContentView alloc]init];
   customContentView.configuration = self; 
   return customContentView;
}

This bug is new in iOS 16.... running the app on iOS 15 and I get the expected behavior.

Are you able to attach a sample project to your feedback report that reproduces the issue? This issue isn't something we have seen before or have received other reports of.

Accepted Answer

Aha. The problem was I forgot to assign the configuration property on the content view! 🤦‍♂️

-(nonnull __kindof UIView<UIContentView>*)makeContentView

{
    CustomContentView *customContentView = [[CustomContentView alloc]init];
   customContentView.configuration = self; 
   return customContentView;
}
iOS 16 UITableView: You are setting a new content configuration to a cell that has an existing content configuration, but the existing content view does not support the new configuration. Existing content configuration is nil.
 
 
Q