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

calling addSubview in initWithNibName: causes viewDidLoad (and other UI Object inits)to fire before the addSubview Call executes

I'm adding a button in the middle of my initWithNibName:bundle:, when i add the button view to self.view, the view goes to start to initialize before it add's the button. So the Code in viewDidLoad gets fires before the initWithNibName:bundle: is…
scooter133
  • 1,297
  • 1
  • 15
  • 29
2
votes
1 answer

UITableView getting Initialized in the middle of viewDidLoad?

I have a VC that I'm initializing, and in it is a View. In the View is a UITableView, UIButton, and UIImage. I was messing with button attributes when all of a sudden, wham: Assertion failure in -[UITableView…
scooter133
  • 1,297
  • 1
  • 15
  • 29
2
votes
3 answers

How to save and load UITextField using NSUserDefaults?

Possible Duplicate: How would I save and load a UITextField? I have tried EVERYTHING and unfortunately nothing works for me. I have probably tested about 10 ways of saving and loading the UITextFields but they don't work. I have six UITextFields…
pixelbitlabs
  • 1,934
  • 6
  • 36
  • 65
2
votes
1 answer

Public properties are always null in ViewDidLoad in a custom TabBarController in MonoTouch

I've been working on a class derived from UITabBarController. At the most basic level, what I'm trying to do is add a BackgroundColor property, and other public properties, that I can instantiate in my AppDelegate when I'm constructing my…
Daniel Crenna
  • 3,326
  • 1
  • 24
  • 34
2
votes
1 answer

iOS - viewDidLoad is being called BEFORE the didFinishLaunchingWithOptions delegate?

I have an application that is working as it was supposed to. However, I put one breakpoint at the first line of my rootViewController's viewDidLoad method and another breakpoint in the first line of my delegate's…
Tiago_Brasil
  • 121
  • 2
  • 9
2
votes
0 answers

iOS 15 Beta keyWindow not available in viewDidLoad

We have a lot of logs to Crashlytics where the keyWindow ist nil after app startup in viewDidLoad of the first viewController show on screen. Anyone else having problems to access UIApplication.shared.keyWindow?.rootViewController on app startup…
Renato Stauffer
  • 738
  • 2
  • 14
  • 30
2
votes
1 answer

injecting UINibExternalObjects to an self initialzied ViewController

I want to navigate from one ViewController to another. As part of this I want to pass the ViewController I want to navigate to some information. I encapsulated the information into an Object that I want to hook up as an external object with the…
Jakob
  • 1,126
  • 3
  • 16
  • 38
2
votes
4 answers

Does it make a difference where to put [super viewDidLoad] in my UIViewController?

Possible Duplicate: [super viewDidLoad] convention Does it make a difference where I put [super viewDidLoad] within the viewDidLoad in my UIViewController? I.e., should it go at the beginning (before my code to set up the UIViewController) or the…
Jason
  • 14,517
  • 25
  • 92
  • 153
2
votes
2 answers

self.tabBarController.selectedIndex not calling viewDidAppear

I've been looking at and trying all the solutions others have posted to this problem, but I'm still not getting it. My use case is very simple. I have a viewController with a button, when that button is pressed I want to navigate to another tab and…
TJMac
  • 129
  • 1
  • 12
2
votes
1 answer

does this code really need a "[self.tableView reloadData]" at the end of viewDidLoad (in a UITableViewController)

The SimpleEKDemo sample has a "[self.tableView reloadData]" at the end of viewDidLoad in the RootViewController.m file. Is this necessary? Any ideas why this line was put in? Wouldn't the view get drawn subsequently after the viewDidLoad via…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
3 answers

Function after presenting Alert Swift

TLDR Is there a way to be notified before a UIAlert is going to be presented. Is there a viewDidLoad/viewWillLoad type function that can be called in a ViewController either before or after an alert pops up? My Problem My View Controller is…
Matt Bart
  • 809
  • 1
  • 7
  • 26
2
votes
1 answer

Can I load a UICollectionView's data in ViewDidLoad?

My app's startup screen is a collection view. If the users choose, he/she can "lock" the app using Face ID/Touch ID at app launch. I do this by presenting a view controller that contains a UIVisualEffectView on top of my collection view…
TonyStark4ever
  • 848
  • 1
  • 9
  • 24
2
votes
4 answers

numberOfItemsInSection func calling before viewdidload()

Here I am first retrieving an image from firebase then adding it to an locationImage array,which will be later added to collectionView. import UIKit import Firebase import FirebaseStorage class ViewController: UIViewController,…
2
votes
2 answers

iOS: view height not set correctly in viewDidLoad

I have a view controller loaded from a nib where I have a scroll view defined with a height of 346 pixels. However when I do: int h = scrollView.frame.size.height; NSLog(@"%d",h); in viewDidLoad I get 375. I need the proper height in viewDidLoad…
Tom H
  • 1,316
  • 14
  • 26
2
votes
3 answers

How to reload view after data changes in Swift

I have a view that contains labels, and have a button to change the values of the labels. Instead of changing the values one by one in the button, how can I reload the whole view to update the labels. @IBOutlet weak var one: UILabel! @IBOutlet…
Difeng Chen
  • 159
  • 3
  • 10