Questions tagged [viewdidload]

Method in UIViewController class (Apple iOS SDK) for managing the view. Called after the controller’s view is loaded into memory.

This method is called after the view controller has loaded its associated views into memory. This method is called regardless of whether the views were stored in a nib file or created programmatically in the loadView method. This method is most commonly used to perform additional initialization steps on views that are loaded from nib files. Available in iOS 2.0 and later.

722 questions
1
vote
1 answer

Perform function on Dismiss of a View Controller

i am calling a GET(method) API on viewDidAppear function of a view controller. i am presenting a new view controller using navigation controller over my first view controller. on the second view controller i am calling an API of Post Method to add…
1
vote
2 answers

viewDidLoad() not called

Either there is something weird in my project (Mojave, XCode10) or I am missing something very basic. This is my whole code: import Foundation import Cocoa class ViewController: NSViewController { public init () { …
MassMover
  • 529
  • 2
  • 17
1
vote
3 answers

Swift How can I keep only the first page with a large title?

The large title of navigation item comes out when the app just describes execution. However, when I move to another page and come back, that mode is turned off. Create a viewDidLoad for each page as follows: What's the problem? class…
1
vote
1 answer

I can print data but can't assign it to a label in Swift

I sent my data from my API call to my InfoController viewDidLoad. There, I was able to safely store it in a skillName constant, and also printed it, receiving all the information by console. The problem comes when I try to assign this variable to my…
3rnestocs
  • 23
  • 7
1
vote
2 answers

viewDidLoad not being called in Swift subclasses inherited from Objc superclass

I have a question about viewDidLoad in Objc versus Swift. I am not familiar with Swift, and I'm trying to embed Swift code into our app for the first time. The swift code I am trying to embed has two classes with inheritance declared this…
1
vote
1 answer

Presenting View Controller is too slow

I have implemented a Firebase Google login into my Swift App. I want to check in the beginning if its already a logged in user or not. I do this like that: override func viewDidLoad() { super.viewDidLoad() …
1
vote
1 answer

Should I call viewDidLoad() inside updateUIViewController(_:context:) in SwiftUI

I create UIScrollView to be integrated inside SwiftUI view. It contains UIHostingController to host SwiftUI view. When I update UIHostingController, UIScrollView does not change its constraints. I can scroll neither to top nor to bottom. When I try…
1
vote
1 answer

memory initialization and viewdidload and order of event execution

I am trying to load a list of assets using the ALAssetsLibrary and enumerateGroupsWithTypes. I populate an NSMutableArrary with the assets loaded so i get to use it later, for instance change a view's background randomly. I tried to preload this…
Hao Chen
  • 11
  • 1
1
vote
1 answer

Place references to IBOutlet and IBAction inside viewDidLoad or just before?

I understand that viewDidLoad is where you are supposed to put any set up code in relation to buttons, color, and other view related code. However, in a code sample I have just seen, a reference to IBOutlet and to IBAction are not written inside of…
timman
  • 479
  • 5
  • 14
1
vote
2 answers

How do I get UIView autoresize rules to fire at viewDidLoad?

I've created an iPad-targeted UIView in Interface Builder with struts and springs. Autoresizing works perfectly once the app is running, as I change the device orientation. But at startup, the UIView has its landscape sizing (as drawn in my xib)…
ed94133
  • 1,477
  • 2
  • 19
  • 40
1
vote
0 answers

AVAudioPlayer multiple stop problem in swift

I have piano keyboard.When I press the key I want the previous key not to be interrupted before calling func pianoKeyUp.So I created another player in pianoKeyDown. The problem is: When simultaneously press the key created AudioPlayers is not…
1
vote
2 answers

Set Nav Bar's color without using .barTintColor?

I am trying to display a user picture in place of the rightBarButton but setting barTintColor of the UINavigationBar tints the image. In the AppDelegate, tried: UINavigationBar.appearance().barTintColor = .blue In the viewDidLoad,…
Ryan
  • 107
  • 7
  • 30
1
vote
1 answer

Delay GameCenter Authentication View Controller from being presentation - Swift 4.2

I am trying to make the GameCenter Authentication View Controller be delayed 2 seconds before being presented. There are about 2 seconds of button animations that take place in my VC and I don't want them to be blocked by the presentation of the…
user10992525
1
vote
2 answers

explanation for Apple's advise to nil objects in "viewDidUnload"?

I would be interested in anyone who can provide a little more information regarding Apple's recommendation below (found in the Core Data tutorial) re nil'ing objects in "viewDidUnload". For example: why this is important? different between…
Greg
  • 34,042
  • 79
  • 253
  • 454
1
vote
1 answer

Is there a way to show a UIelement that was previously hidden in earlier lines of code after a button has been tapped on the same VC in Swift?

I have many UI elements on a VC including labels, textfields, and a button. In the viewDidLoad() function, most of the UI elements are initially hidden. I have successfully programmed the UIButton on the VC to change the label text and button title…