Questions tagged [viewdidlayoutsubviews]

52 questions
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
  • 40,656
  • 60
  • 209
  • 315
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
vote
0 answers

Swift 4: didSet @IBOutlet calls viewDidLayoutSubviews, but not with addSubview()

When selectCard is called, by commenting out various parts of the code I've discovered that viewDidLayoutSubviews is only called when score is updated in checkIfCardsMatch function. The score is only updated if we have matchedCards. Why is this…
Turnipdabeets
  • 5,815
  • 8
  • 40
  • 63
1
vote
2 answers

Auto resizing corner radius using viewDidLayoutSubviews() not updating the view before it is displayed

I'm new to swift and Xcode so there may be a simple answer or better way to do this. I am trying to make rounded edges to my buttons in all size iOS devices and the best way that I have found so far is using this method: override func…
Jared L.
  • 207
  • 2
  • 13
1
vote
2 answers

iOS 11.0.1 crash in viewDidLayoutSubviews

I have several UIViews in my ViewController that are initially hidden. They become unhidden once I get a successful response from Firebase. These initially hidden views have constraints (from Storyboard) that I am modifying in…
Joe
  • 3,772
  • 3
  • 33
  • 64
1
vote
2 answers

Incorrect Frame Position when defined in ViewDidLayoutSubviews

I have an imageView inside an ovalView constrained with auto layout. Inside viewDidLayoutSubviews(), I am creating a UILabel let label = UILabel(frame: imageView.frame) imageView.superview?.addSubview(label) The frame of label shows slightly…
Kashif
  • 4,642
  • 7
  • 44
  • 97
1
vote
2 answers

iOS 10 Auto Layout - viewDidLayoutSubviews called repeatedly

The whole Storyboard is AutoLayout enabled. When I put a log inside viewDidLayoutSubviews(), I can see it's called repeatedly, and never stops. I don't have any auto layout red flags in the view controller. What could be causing this? What would be…
1
vote
0 answers

How to get callback for device size specific auto-layout in Swift/iOS?

I want to place few buttons/images in my UIView after auto-layout has completed the layout for device on which the app is being run. E.g. in my storyboard, I have screen size set to iPhone 7. But after auto-layout is completed for the device (say…
1
vote
0 answers

Swift: Subview Listens for Parent to call viewDidLayoutSubviews

I have a custom collection view whose cell sizes are determined by the view controller. Because the layout is set before the cell size (cell size is set in cellForItemAtIndexPath), the layout does not work correctly unless it is set inside of the…
1
vote
2 answers

When does a UIView know how big it is?

I have a subclass of UIView that draws a picture onto itself using CAShapeLayers. I want the drawing to adapt to whatever size the UIView is given by AutoLayout. I gave it a drawGraph() function that gets its current size from .bounds.size and then…
Robert
  • 6,660
  • 5
  • 39
  • 62
1
vote
1 answer

Cannot unhide a button except in ViewDidLayoutSubviews()

I have a UIButton that should only be appearing sometimes. In the viewDidLayoutSubviews I did the following: override func viewDidLayoutSubviews() { super.viewWillLayoutSubviews() clearButtonOutlet.hidden = true However, when I try to do…
Sami
  • 579
  • 5
  • 25
1
vote
0 answers

How to layout the originalContentView, when canDisplayBannerAds is YES?

I've always wanted to develop word games, so I have purchased an app template - to learn from the source code. After I have converted the template to ARC and to Storyboard I would like now to start using iAd in my app. However when I put…
1
vote
3 answers

viewDidLayoutSubviews is called when label changes (xcode) (swift)

I have a label, toggle button and an animation in my code. When I press the toggle button -> animation starts , label changes. Below is my code sample. override func viewDidLayoutSubviews() { println("viewDidLayoutSubviews is called") // Initial…
0
votes
0 answers

Why viewDidLayoutSubviews is called twice only on initialize?

I am going to use it by adding a child VC. (Coding with code) ChildVC is using autolayout (snapkit). At initialization, viewDidLayoutSubviews is called twice. At the first call, the childVC.View is set to full screen Frame. In the second call, it is…
jkey
  • 3
  • 2
0
votes
1 answer

The difference between viewDidLayoutSubviews and NSLayoutConstraint

Please explain the difference. I watch the lesson on YouTube (LINK) The guy uses viewDidLayoutSubviews when he could have used NSLayoutConstraint. override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() firstNameField.frame =…