Questions tagged [viewdidlayoutsubviews]

48 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
  • 21,612
  • 9
  • 111
  • 127
11
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…
8
votes
1 answer

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
  • 3,622
  • 3
  • 29
  • 54
8
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,029
  • 2
  • 27
  • 52
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
  • 7,877
  • 8
  • 52
  • 92
3
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…
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 =…
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,163
  • 3
  • 16
  • 35
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
  • 3,747
  • 4
  • 37
  • 77
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

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
  • 47,708
  • 70
  • 236
  • 372
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
  • 6,390
  • 1
  • 38
  • 56
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
  • 33,997
  • 43
  • 149
  • 241
1
vote
2 answers

UIViewController viewDidLayoutSubviews

I am having difficulty figuring out why Erica Sadun does the following (calling viewDidAppear in viewDidLayoutSubviews) in her cookbook example Ch07-11. Perhaps the two methods should be calling another method instead? See:…
Boon
  • 37,606
  • 51
  • 186
  • 296
1
vote
0 answers

Why viewDidLayoutSubviews and viewWillLayoutSubviews is not getting called in view controller

I have a viewcontoller Called P. Whenever I rotate the screen , viewDidLayoutSubviews is getting called in P. But sometimes it's not getting called in P and I don't why it happens like that and I don't know how to fix this issue. Here is the…
1
2 3 4