I recently had a problem in my app where some of the subviews I was creating in a UIViewController subclass's -awakeFromNib
method were disappearing from the view. After some poking around I found that moving the code I had put in -awakeFromNib
to -viewDidLoad
solved the problem. Seems that -awakeFromNib
gets called only once when the UIViewController is unarchived from the nib, and -viewDidLoad
gets called every time the view is unarchived.
So what's the best practice? It looks like UIViewController's -awakeFromNib
shouldn't be adding any views to the view, that kind of stuff should be done in -viewDidLoad
. Am I understanding this correctly? Or am I more confused than I thought?
Single quotation marks are also known as 'quote marks', 'quotes', 'speech marks' or 'inverted commas'. Use them to: show direct speech and the quoted work of other writers. enclose the title of certain works.
General Usage Rules In America, Canada, Australia and New Zealand, the general rule is that double quotes are used to denote direct speech. Single quotes are used to enclose a quote within a quote, a quote within a headline, or a title within a quote.
Or is a conjunction that connects two or more possibilities or alternatives. It connects words, phrases and clauses which are the same grammatical type: Which do you prefer? Leather or suede?
Use double quotation marks (“”) around a direct quote. A direct quote is a word- for-word report of what someone else said or wrote. You use the exact words and punctuation of the original.
awakeFromNib
is called when the controller itself is unarchived from a nib. viewDidLoad
is called when the view is created/unarchived. This distinction is especially important when the controller's view is stored in a separate nib file.
Also important is that the awakeFromNib
function will never be called after recovering from memory warning. But, the viewDidLoad
function will be called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With