Questions tagged [viewdidlayoutsubviews]

52 questions
28
votes
1 answer

UIView/CALayer: Transform triggers layoutSubviews in superview

When changing some of the properties for UIView it triggers layoutSubviews in the superview. I can not find any statements about this in the docs. These properties triggers layout in superview and self frame bounds These properties triggers…
hfossli
  • 22,616
  • 10
  • 116
  • 130
12
votes
2 answers

Quick 180 rotation of iOS Device results in the camera viewing upside-down

I've implemented the code below to change the orientation of an AVCaptureVideoSession based upon the UIInterfaceOrientation: - (AVCaptureVideoOrientation)interfaceOrientationToVideoOrientation:(UIInterfaceOrientation)orientation { switch…
10
votes
2 answers

What's exactly viewDidLayoutSubviews?

I was reading the description of viewDidLayoutSubviews of UIViewController: Called to notify the view controller that its view has just laid out its subviews [...] However, this method being called does not indicate that the individual layouts of…
MartinMoizard
  • 6,600
  • 12
  • 45
  • 75
10
votes
2 answers

Why viewDidLayoutSubviews is called twice only on first run?

It's driving me crazy this. Only on first run the viewDidLayoutSubviews is called twice. Here is the code I'm using: class CICViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } func…
George Asda
  • 2,119
  • 2
  • 28
  • 54
9
votes
2 answers

iOS 13 - viewDidLayoutSubviews called on changing frame

There is some change done in viewdidlayoutsubviews in iOS 13 that is causing it to be called later in the life cycle of the View Controller once it has finished its first callings (on changing frame). This is creating some weird effects in the apps.…
Hassy
  • 5,068
  • 5
  • 38
  • 63
4
votes
2 answers

viewDidLayoutSubviews no longer called when popping top view with UINavigationController

iOS 10, the gift that keeps on breaking, seems to have changed another behavior. Assume two UIViewControllers are pushed onto a UINavigationController. On iOS 8/9, calling navigationController?.popViewController(animated: true) to pop the top…
4
votes
1 answer

At what point are a UIViewController's subviews definitely laid out initially?

I have many places in my code where I need to do stuff based upon the layout of the views in a UIViewController. For example, I have a view in a nib that I then capture in code and use to create a mask for another layer, but I need to wait until the…
jowie
  • 8,028
  • 8
  • 55
  • 94
3
votes
0 answers

UIColllectionView not respecting layout

I want to change my collection view layout after rotation in order to change the cell size. In the simulator works great. On iPhone 6 doesn't. Code is as follows: -(void)viewDidLoad { UICollectionViewFlowLayout *layout =…
Avba
  • 14,822
  • 20
  • 92
  • 192
3
votes
1 answer

Why changing the UILabel text fires a viewDidLayoutSubviews event?

There are lots of viewDidLayoutSubviews events fired in my ViewController. Eventually I narrowed down to the single line of code which triggers the event: self.debugLabel.text = [NSString stringWithFormat:@"%@ - %@", key, [@(tag) stringValue]]; Its…
ohho
  • 50,879
  • 75
  • 256
  • 383
3
votes
0 answers

Xcode 6 beta and resizable Iphone: How to get the current Screen Dimensions

I try to make my Views completely dynamic so the Views can fit any Screen Dimensions. At the Moment i get the screen Width and Height for calculation like this: CGFloat getDisplayHeight() { CGSize result = [[UIScreen mainScreen] bounds].size; return…
Davis
  • 1,253
  • 4
  • 17
  • 38
2
votes
1 answer

viewDidLayoutSubviews stuck in infinite loop for blank method

I have a view controller that is setup with a UITableView in UIStoryboard. The UITableView is constrained to the SafeArea of the controller on all four sides. It may seem that this question has been asked before, but each time I have found the…
SAHM
  • 4,078
  • 7
  • 41
  • 77
2
votes
1 answer

where to put manual layout code for a UIView where parent views use autolayout?

Where to put manual layout code (or where to trigger it) for a specific child UIView I have, when the parent views themselves utilise autolayout? Notes: layout code for the view needs to use its frame dimensions after any parent view layout,…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
0 answers

Attempt to present MPMoviePlayerViewController while a presentation is in progress

I get warning described in title and I've found that this is as a result of calling viewDidLayoutSubviews multiple times. - (void) viewDidLayoutSubviews { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"wq"…
Minoo
  • 139
  • 11
2
votes
1 answer

How to get canDisplayBannerAds producing viewDidLayoutSubview callbacks?

In my code, when I set canDisplayBannerAds=YES on my view controller, I get callbacks to viewDidLayoutSubviews when the ad disappears but not when the ad appears. I'm guessing this is because Apple moves the original self.view of the view controller…
Chris Prince
  • 7,288
  • 2
  • 48
  • 66
2
votes
2 answers

How do I get the correct view height in viewDidLayoutSubviews?

- (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; NSLog(@"viewDidLayoutSubviews view.height: %f", self.view.frame.size.height); } In the above, view.height is always 1024 regardless of what orientation the device is in. Even…
devios1
  • 36,899
  • 45
  • 162
  • 260
1
2 3 4