Questions tagged [uitraitcollection]

UITraitCollection - allow to access the iOS interface environment by traits such as horizontal and vertical size class, display scale, and user interface idiom

84 questions
2
votes
1 answer

How to create UITraitCollection with both size classes in code?

I have a simple extension for UITraitCollection: extension UITraitCollection { var isIpad: Bool { return horizontalSizeClass == .Regular && verticalSizeClass == .Regular } } Before, I have needed to write tests for this (using…
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
2
votes
1 answer

traitCollection.horizontalSizeClass reports Compact on iOS 8.1, Regular on iOS 8.4 and 9.x

I am adding a Done button in the code to the Navigation Bar for a UIViewController subclass for iPad only, more precisely for Regular Size Class with the below code. We support iOS 8+. The if statement returns Compact Size Class when run on iPad Air…
Martin Koles
  • 5,177
  • 8
  • 39
  • 59
2
votes
0 answers

viewDidLoad and self.traitCollection undefined

I'm seeing times when self.traitCollection is undefined in viewDidLoad: If I do the following simple presentation - the traits are NOT set (in viewDidLoad:) TableViewController* vc = [[TableViewController alloc]…
Scotty
  • 2,019
  • 1
  • 20
  • 31
2
votes
1 answer

Prevent a UIPopover from being presented as UIPageSheet on iPhone 6 plus in landscape

I'm trying to show a popOver with a UISlider inside, to allow an user to control the textSize of a WKWebView. Here is how I did it: MYCustomViewController *popoverContent = [[self storyboard]…
2
votes
0 answers

Size Classes and dequeueReusableCellWithIdentifier

I am trying to calculate height of UITableViewCells. I have this working creating a prototype cell instance from a dynamic prototype configured in the storyboard by calling -dequeueReusableCellWithIdentifier: on the UITableView and then calling…
1
vote
1 answer

How to get target UITraitCollection as well as target rect

I have a tool pane which in compact H mode, will be at the bottom spanning the full screen, but in compact V mode (or non compact H mode), it will be on the right as a floating pane. How do I get the target UITraitCollection + the target size? They…
Mike S
  • 4,092
  • 5
  • 35
  • 68
1
vote
0 answers

SwiftUI, is there a traitCollectionDidChange-like method in a View?

I'm researching SwiftUI to see if it fits our compony's use case. However, I find it rather bare bones and wonder wether I am missing some key insights. Currently I am researching if V/HStack's can respond dynamically to Accesability font-size…
Arne Oldenhave
  • 201
  • 1
  • 3
  • 12
1
vote
1 answer

traitCollectionDidChange never called on UIView subclass

I have a UIViewController that is presented modally by another UIViewController. This UIViewController has a UITableView with a custom UIView set for it's tableFooterView. So the issue I am having is: some colors are not displayed properly when…
Tomer Ciucran
  • 199
  • 1
  • 10
1
vote
1 answer

How do I detect dark/light mode changes in my AppDelegate in order to reset global tintColor?

In my AppDelegate, I set the global tint color. How can I be notified when the user enables/disables dark mode in order to reset global tint? In my AppDelegate, I have: @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { …
1
vote
1 answer

Is it possible to manually set / toggle the UserInterfaceStyle / Dark Mode per App?

I have updated my iOS 11+ to support Dark Mode when being used on iOS 13. This works fine when the UserInterfaceStyle / Dark Mode is enabled or disable in the device settings. However, I would like to give users the option to activate / deactivate…
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
1
vote
1 answer

How do i resolve default iOS elements to a particular trait?

How do i resolve a default iOS system element, like say UISegmentedControl, to a particular interface style? I know colors can be resolved like this. color.resolvedColor(with: UITraitCollection(userInterfaceStyle: .dark)) How do i do the same for…
Rakesha Shastri
  • 11,053
  • 3
  • 37
  • 50
1
vote
0 answers

UIViewController modalPresentationStyle popover for iPad and custom for iPhone

I created a custom presentation using UIPresentationController but I only want to use this presentation for horizontally compact layout, and I want to replace my custom presentation with a popover for horizontally regular layout, and when the…
1
vote
0 answers

traitCollectionDidChange not called on window

I have a situation where I need to inject a full screen view on the window. For whatever reason, inserting the full screen view on `window.rootViewController.view' is not an option. The full screen view responds to trait collection changes…
Matt.M
  • 1,039
  • 3
  • 14
  • 21
1
vote
0 answers

Trait Variation Not Found For UIButton attributed font

Trait variation is shown when button's title font is Plain. Please see below image: But when the title font is changed to attributed, the plus icon disappears. Please see below image: Can anyone please help me with how to add trait variations for…
iPeter
  • 1,330
  • 10
  • 26
1
vote
1 answer

Swift: how to switch statusbar orientation in IOS 9+?

I'm building a game that is based on gestures. IOS' native gestures that bring in notification center and control center on side swipe are super annoying as they interfere with gameplay. Having searched extensively for a solution, I have come to…
user594883
  • 1,329
  • 2
  • 17
  • 36