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
1
vote
0 answers

How can I override the trait collection for a view controller with a custom modal presentation style?

I have a custom modal presentation style for view controllers in my app that mimics a form sheet, except with some additional visual touches. View controllers that are presented like this make some layout decisions based on attributes of their trait…
1
vote
0 answers

Wrong size classes for iPad on Simulator (TraitCollection)

I have following code in my UIViewController: override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) let horizontalSizeClass =…
AndrzejZ
  • 245
  • 2
  • 10
1
vote
0 answers

How to get UIModalPresentationPageSheet frame after traitCollectionDidChange

Some strange behavior occurs when I use multi tasking and try to get frame of the UIViewController. I use: - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection To update frame of the views after we change application trait…
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100
1
vote
2 answers

UIView frame not updated during traitCollectionDidChange

I did some drawing using CALayer based on the frame in my subclass of UIView, I need to update the lines when the device rotate but in traitCollectionDidChange, the frame is still holding the value before the rotation. Is there a way to get the…
Ben Ong
  • 913
  • 1
  • 10
  • 25
1
vote
1 answer

Reorganizing Toolbar and NavigationBar after TraitCollectionDidChange

I want to support a layout similar to Safari, where in horizontally regular environments, buttons are displayed on the navigation bar, but in horizontally compact environments, some buttons are on the navigation bar and some buttons are on the…
CompC
  • 381
  • 2
  • 19
1
vote
1 answer

I`ve read that MVC can find out its size class environment via this method in UIViewController

let mySizeClass: UIUserInterfaceSizeClass = self.traitCollection.horizontalSizeClass and the return value will be an enum .Compact or .Regular (or .Unspecified). When I try it in code compiler shows me a warning: Value of type 'NSObject -> () ->…
Vitya Shurapov
  • 2,200
  • 2
  • 27
  • 32
1
vote
0 answers

iOS - Trait Collection Events Selectively Called

I have a main view controller with a series of buttons and a content view. When a button is pressed, all the subviews are removed from the content view, and a new one is loaded. It's essentially a custom tab bar controller with some extra…
Nathan Tornquist
  • 6,468
  • 10
  • 47
  • 72
1
vote
1 answer

Navigation pop animation unexpected - jumps off screen

I'm having an issue where my UINavigationController's default pop animation has unexpected behavior - the popped controller sometimes jumps off-screen left or right. The issue seems related to overriding the controller's UITraitCollection. I have a…
beebcon
  • 6,893
  • 5
  • 25
  • 27
1
vote
1 answer

iOS8 change UIPopoverPresentationController trait collection

I'm deploying an application on both iphone and ipad (iOS7 and iOS8). I'm using storyboard with size classes, basically I have a base size classes Any-Any that fits iPad layout and a Compact-Regular that fits all iphone models. Some view controllers…
Andrea
  • 26,120
  • 10
  • 85
  • 131
1
vote
1 answer

UITraitCollection - swift to objective-C

I'm trying to convert swift to objective-C. Here is my code below: Swift import UIKit protocol TraitCollectionOverridable { func preferredTraitCollection() -> UITraitCollection? } class CustomNavigationController: UINavigationController { …
DesperateLearner
  • 1,115
  • 3
  • 19
  • 45
0
votes
2 answers

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 able to respond to changes in the interface…
0
votes
0 answers

traitCollection.legibilityWeight causes UIView.animate to ignore delay and duration

I have this repeating animation where a backgroundColor phases back and forth between two options private func phase() { let duration = TimeInterval.random(in: 1.2...2.6) let delay = TimeInterval.random(in: 0.2...3.0) …
Magoo
  • 2,552
  • 1
  • 23
  • 43
0
votes
0 answers

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 the current safe areas, not the one for opposite…
Khal
  • 790
  • 5
  • 23
0
votes
0 answers

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. This is my first time developing app for all…
Mel
  • 429
  • 1
  • 4
  • 12
0
votes
1 answer

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. For example, the system assigns the…
Jordan H
  • 52,571
  • 37
  • 201
  • 351