88 questions
0
votes
1
answer
671
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
369
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
797
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
14k
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
331
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
970
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
739
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
650
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
346
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
854
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
3k
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
...
0
votes
1
answer
257
views
super initWithFrame returned nil from -traitCollection, which is not allowed
I'm running one of my Objective-C project on XCode 12.0. I have UIControl subclass "SeatingPanelControl" from which another subclass is created named "IpadSeatingPlanControl", ...
0
votes
2
answers
237
views
Horizontal size class of popovers in Catalyst?
If I present a view controller as a popover on iPad (by setting its modalPresentationStyle to .popover), it will report its horizontal size class as .compact. But if I run the same code in a Catalyst ...