90 questions
-1
votes
0
answers
46
views
'init(frame:)' was deprecated in iOS 26.0: Use init(windowScene:) instead
I am using this file from swift-snapshot-testing library. After updating my project to iOS 26, I need to fix all the warnings. But I am not sure how to fix this one:
'init(frame:)' was deprecated in ...
-1
votes
0
answers
52
views
'init(traitsFrom:)' was deprecated in iOS 17.0, How do I use the new UITraitCollection.init(mutations:)?
I am using this file from swift-snapshot-testing library. After updating my project to iOS 26, I need to fix all the warnings. But I am not sure how to fix this one:
'init(traitsFrom:)' was ...
0
votes
1
answer
565
views
Using UIDesignRequiresCompatibility for tabbar which is having issue with liquid glass. Initially tabbar loads it shows 5 tabs instead of 6
Using UIDesignRequiresCompatibility to have backward compatibility with 6 tabs based TabbarController using traitCollection. but the issue is initially loads 5 tabs & when app goes to background &...
1
vote
1
answer
302
views
Custom trait propagation not working as expected outside of view hierarchy
I'm trying to build custom-styled components that can handle a custom trait propagated from above and adjust their styling accordingly. E.g.:
class CustomButton: UIButton {
override init(frame: ...
3
votes
1
answer
737
views
How to implement custom traits in Objective-C?
The WWDC 2023 video Unleash the UIKit trait system discusses new UIKit APIs added in iOS 17 related to custom traits in trait collections. The video and its associated code is all in Swift but I wish ...
12
votes
1
answer
13k
views
‘traitCollectionDidChange’ was deprecated in iOS 17.0. How do I use the replacement?
I am trying to work with this function but it does not work with iOS 17.
I want to make a change every time I switch between dark and light mode.
This is my function:
override func ...
1
vote
0
answers
320
views
traitCollectionDidChange not called on scheduled appearance (dark mode / light mode) change (e.g. at sunset / sunrise, or custom schedule)
I have a navigation app. During a navigation session, I prevent the screen from sleeping. When users are driving/navigating around sunrise or sunset, appearance should change between light and dark ...
0
votes
1
answer
905
views
How can I detect when the system changes dark/light mode in Swift?
I know there are plenty of answers pointing to traitCollectionDidChange, but that is going to be called when the userInterfaceStyle of a view controller changes, and I would like to let the user ...
0
votes
2
answers
722
views
Should I use viewDidLayoutSubviews() or traitCollectionDidChange() to respond to changes in interface orientation
I'm trying to update the constraints and change the layout of my subviews when the user rotates their device.
From what I understand, both viewDidLayoutSubviews() and traitCollectionDidChange() are ...
1
vote
0
answers
642
views
iOS safe area insets for both portrait and landscape before adding a view to the hierarchy?
For various optimization purposes, I want to get the device's max display size without the safe areas for both portrait and lanscape.
I can use the UIWindow's safeAreaInsets, but that only gives me ...
0
votes
0
answers
345
views
how to adjust layout of tableview cells having collectionView on screen rotation on all screen sizes?
I have CollectionView embedded in TableView cells to show images posted by a user. Im targeting this app on every device from iPhone 8 to Mac and I do have screen rotation on for iPhones and iPads. ...
0
votes
1
answer
827
views
How to assign a view's UIUserInterfaceLevel?
The documentation for UITraitCollection's userInterfaceLevel states:
When you want parts of your UI to stand out from the underlying background, assign the UIUserInterfaceLevel.elevated level to them....
5
votes
2
answers
2k
views
Why is traitCollectionDidChange not called for a table view cell when content size category changes?
I have a view controller that contains a table view and displays custom cells. I'm trying to react to a content size category change using the traitCollectionDidChange method (within the cell subclass)...
0
votes
1
answer
471
views
Swift 5 UICollectionViewCell Autolayout constraints
I am working on remastering Swift and UIKit after a long time.
WorkFlow:
I have created a ViewController with a UICollectionView aligning its centers in both X and Y axis and Proportional Width and ...
4
votes
3
answers
6k
views
Xcode 13 beta 5 error: UIViewController is missing its initial trait collection populated during initialization
App was working fine until Xcode 13 beta 5 builds.
Suddenly get this error in this init line of code in our view controller:
init(dataProvider: DataProvider) {
self.dataProvider = dataProvider
...