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
167
votes
4 answers

UIViewController viewDidLoad vs. viewWillAppear: What is the proper division of labor?

I have always been a bit unclear on the type of tasks that should be assigned to viewDidLoad vs. viewWillAppear: in a UIViewController subclass. e.g. I am doing an app where I have a UIViewController subclass hitting a server, getting data, feeding…
dugla
  • 12,774
  • 26
  • 88
  • 136
83
votes
1 answer

UIView - How to get notified when the view is loaded?

Is there anything similar to the viewDidLoad of UIViewController for a UIView??? I need to be notified as soon as a UIView has loaded (Subclass of UIView), and perform some actions.
aryaxt
  • 76,198
  • 92
  • 293
  • 442
54
votes
8 answers

Do I always have to call [super viewDidLoad] in the -viewDidLoad method?

In Apple's scrollView example they don't call that. I always thought that's a must. Why should I call that anyways?
Thanks
  • 40,109
  • 71
  • 208
  • 322
43
votes
3 answers

Unable to set frame correctly before viewDidAppear

I was wondering if anyone knows why when you set the frame of a subview in viewDidLoad and viewWillAppear the changes do not take affect on the screen, but if you set it in viewDidAppear they do? In my case I am loading a custom xib with two…
nacross
  • 2,013
  • 2
  • 25
  • 37
35
votes
3 answers

Android's viewDidLoad and viewDidAppear equivalent

Does Android have an equivalent to Cocoa's viewDidLoad and viewDidAppear functions? If not, then how would I go about performing an action when a View appears? My app is a tabbed application, in which one of the tabs is a list of forum topics. I…
Code Slinger
  • 1,100
  • 1
  • 11
  • 16
35
votes
1 answer

difference between awakeFromNib() and viewDidLoad() in swift

I want to know the key difference between awakeFromNib() and viewDidLoad() to get more clarity on how it works . Please can anybody explain?
sriram hegde
  • 2,301
  • 5
  • 29
  • 43
32
votes
2 answers

Why am I having to manually set my view's frame in viewDidLoad?

I have a pretty basic setup with a UINavigationController inside a UITabBarController. I'm wanting to programmatically layout the view of the rootViewController of that navcontroller, but when I look at self.view.frame inside viewDidLoad, I get this…
Ryan Waggoner
  • 589
  • 1
  • 7
  • 13
29
votes
6 answers

viewDidLoad called before prepareForSegue finishes

I was under the impression that viewDidLoad will be called AFTER prepareForSegue finishes. This is even how Hegarty teaches his Stanford class (as recently as Feb 2013). However, for the first time today, I have noticed that viewDidLoad was called…
Michael Guren
  • 349
  • 1
  • 3
  • 6
28
votes
4 answers

Force viewDidLoad to fire on iOS

I have two window app and while I present first window I would like the view in second window to load and prepare content for later in background. I've tried to use method loadView but Apple says you should not call this method directly. So far I've…
Borut Tomazin
  • 8,041
  • 11
  • 78
  • 91
25
votes
3 answers

Do I programmatically add SubViews in ViewDidAppear, ViewDidLoad, ViewWillAppear, the constructor?

I'm trying to figure out from Apple's sketchy documentation which method is the best place to be initializing and adding my Views controls to the controller's view. With winforms it's fairly straightforward, as they're always initialized inside…
Chris S
  • 64,770
  • 52
  • 221
  • 239
21
votes
12 answers

viewDidLoad getting called twice on rootViewController at launch

Anyone know why this root View Controller's viewDidLoad is being called twice at launch? It's driving me nuts! here's the stack trace from first time through viewDidLoad: #0 0x0000276a in -[RootViewController viewDidLoad] at…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
18
votes
3 answers

iOS: How to know if viewDidLoad got called?

Is there a BOOL or some other way of knowing if viewDidLoad: has been called? I need to change a view property every time my view has entered active, but if the view hasn't ever been loaded, I don't want to prematurely trigger viewDidLoad:. If there…
kev
  • 7,712
  • 11
  • 30
  • 41
17
votes
6 answers

Is there an iOS method that fires when Autolayout has completed?

I have an iOS app in which I need to know when a new view is completely visible on-screen; that is, when Autolayout has finished its calculations and the view has finished drawing. ViewDidAppear seems to fire well before the view is completely…
Kent
  • 1,705
  • 3
  • 16
  • 26
16
votes
7 answers

viewDidLoad(), LoadView()

What is the difference between viewDidLoad() and LoadView()? In what way are they different from each other? Which one is better when we develop applications without using XIB ? Thanks .
iOS
  • 423
  • 1
  • 6
  • 15
14
votes
2 answers

Perform Segue in ViewDidLoad

I`m trying to perform a segue if its the first time the app is loading. I can see my print message in the debugger, but the Perform Segue is not working. I don't get any errors. Can somebody please tell me whats wrong? import UIKit import…
Paal Aune
  • 353
  • 5
  • 10
1
2 3
48 49