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
2
votes
3 answers

How to run a function every time a UIViewController is loaded

I have this function : func setMoneyValues() { balanceLabel.text = User.current.roundBalance() oweLabel.text = User.current.roundOwed() userLabel.text = User.current.roundUser() } that i execute in viewdidload. However,…
Alec
  • 8,529
  • 8
  • 37
  • 63
2
votes
2 answers

becomeFirstResponder not showing from viewDidLoad

Here I have a simple example. im calling FirstResponder in viewDidLoad. But accessory view only shows up after tapping the screen. Why isn't it showing from the start? class TestViewController: MainPageViewController { private let…
HelloimDarius
  • 695
  • 5
  • 23
2
votes
2 answers

Xcode Swift 3 Picker: Putting the DataSource in ViewDidLoad

I am trying to set up a picker that would display different results based on certain conditions. The only issue is that I need to put the dataSource (picker data that will display) outside the viewDidLoad. I need the viewDidLoad to load the…
Kevin
  • 1,189
  • 2
  • 17
  • 44
2
votes
2 answers

Is there a difference between global Initialization vs viewDidLoad initialization in Swift

If I have a class and initialize a variable like so: class TestClass: UIViewController { var thisInt: Int = 10 } is that any different than initializing like so: class TestClass: UIViewController { var thisInt: Int! override func…
Sethmr
  • 3,046
  • 1
  • 24
  • 42
2
votes
0 answers

Force refresh of Upstream TabViewController

I am developing an app wherein a user action should lead to the reduction of TabController options (icons) from 5 down to 3. I understand the code required to modify the TabController but am unable to force it to refresh (viewDidLoad) since the…
2
votes
3 answers

Is there any way to avoid calling viewdidload method like tabbarcontroller?

I'm developing an application which will work based on maps. So once user opens MapViewController then I will load some data every 5 seconds. I'm using navigation controller(Push view controller). So every time when user goes to MapViewController…
Himanth
  • 2,381
  • 3
  • 28
  • 41
2
votes
1 answer

Presenting view controller's viewDidLoad getting called after presented view controller dismissed

I have a view controller that presents another view controller like so override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = .white let qrScannerViewController = QRScannerViewController() …
mwild
  • 1,483
  • 7
  • 21
  • 41
2
votes
1 answer

What is the pair method for viewDidLoad if viewDidUnload is deprecated?

Is it dealloc or which method? If I setup some code in viewDidLoad, I want to unistall this setup from the pair method of viewDidLoad.. For example viewDidLoad & viewDidDisappear combo is not always clever combination. And sometimes is better to do…
luky
  • 2,263
  • 3
  • 22
  • 40
2
votes
1 answer

Mistake in autoResizingMask

i have implemented a small viewDidLoad() to show an Picture with autoresizing, but it doesn't work, could please someone help me and say what is the mistake in this code in line 3 and 4???? imageView = [[UIImageView alloc] initWithImage:img]; …
Marco
  • 461
  • 1
  • 10
  • 22
2
votes
2 answers

ViewDidAppear and ViewWillAppear is being called multiple times on one viewDidLoad in ios swift app

I am making iPhone app on swift,here ViewDidAppear and ViewWillAppear is being called multiple times on one viewDidLoad in ios swift app? please help me.
sulabh qg
  • 1,155
  • 2
  • 12
  • 20
2
votes
3 answers

Home button doesn't exit app in iPhone simulator 4.0

I noticed that when building then running viewDidLoad only gets called once. If you press the home button and re-enter the application, viewDidLoad does not execute again. Another thing I noticed is that when you re-enter an application it starts…
node ninja
  • 31,796
  • 59
  • 166
  • 254
2
votes
3 answers

Parse - How do I check for a logged in user before the view loads?

I am trying to verify if there is a user before deciding whether to display the login/signup view controller or the logged in view controller. The issue I am running into is that to check for the presence of a user, I have to wait for…
123
  • 8,733
  • 14
  • 57
  • 99
2
votes
1 answer

UICollectionView not the right size in viewDidLoad

I have a simple UICollectionView defined in my storyboard (see screenshot). I'm using auto layout, the UICollectionView is attached to the superview for leading, trailing and top and to the toolbar for the bottom. When I display in the console the…
sebastien
  • 2,489
  • 5
  • 26
  • 47
2
votes
3 answers

A way to reload the ViewDidLoad on each run swift

I'm making this small game with swift and the game is set up using the viewDidLoad. Each day the game is suppose to be slightly different, but that depends on that the viewDidLoad runs. So let's say a user plays at day 1 and keeps the game active to…
JoakimE
  • 1,820
  • 1
  • 21
  • 30
2
votes
1 answer

iOS 4 Unable to access variable crashes app

Under iOS 4, when my app installs from xcode it crashes on the first launch but not on subsiquent launches. After commenting out some addSubView methods the debugger is finally giving me one piece of info It crashes on [super viewDidLoad]. The…
yesimarobot
  • 283
  • 7
  • 16