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
3
votes
1 answer

viewDidLoad being called before didSelectRowAtIndexPath

I have viewDidLoad (of next tableView) being called before didSelectRowAtIndexPath (of current tableView). I am using a 'singleton' to hold my model and up to now this has been working quite well. I am trying to pass on the row selected in the…
3
votes
3 answers

iOS - passing Sender (button) name to addSubview

I have a main view with 3 buttons. Clicking on any of the buttons adds a SubView. The buttons have different titles and are all linked to IBAction "switchView" The "switchView" code is below. - (IBAction)switchView:(id)sender{ secondView…
user885483
  • 107
  • 1
  • 2
  • 10
3
votes
2 answers

Best practice for adding/removing observers to/from NSNotificationCenter

What's the best practice for adding and removing observers to/from NSNotificationCenter? I'm wondering if adding self as an observer in viewDidLoad and removing self in viewDidUnload is sufficient. Or perhaps I should remove self in dealloc as…
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
3
votes
1 answer

viewDidLoad not working (without NIB)

I have been a big fan of this site for a long time, but this is my first posted question. I have read every post similar to the topic (I think), however they all are using NIB files. I have NO nib files anywhere in my project. It's a simple project…
3
votes
5 answers

Xcode 4.2 debugging on a viewDidLoad or viewDidDisappear will end on a EXC_BAD_ACCESS

Xcode 4.2 debugging on a viewDidLoad or viewDidDisappear will end on a EXC_BAD_ACCESS It breaks on that breakpoint but when continuing ("Continue program execution") it returns a: EXC_BAD_ACCESS (code=1, address=0x....) on Thread 1 (0 start). That…
BeMyGuestPlease
  • 531
  • 1
  • 4
  • 13
3
votes
3 answers

This Code works on iOS4.3 not iOS5

The following code works as expected on iOS4.3 iPhone and iPad, and iOS5 iPhone, but crashes on iOS5 iPad. This is called for the first view that I call in a Tab based application, when the prior run of the application was cancelled. The user can…
Michael Rowe
  • 870
  • 2
  • 11
  • 27
3
votes
4 answers

"self.navigationItem.rightBarButtonItem" Not working

I have the following code taken straight from the NavBar sample code from Apple. I put this in the viewDidLoad method for a view in my app that is being presented modally, and it wont work. UIBarButtonItem *addButton = [[[UIBarButtonItem alloc]…
tarheel
  • 4,727
  • 9
  • 39
  • 52
3
votes
3 answers

Weird behavior running MPMoviePlayerController in viewDidLoad

I'm using the MediaPlayer framework to play a pretty sizeable movie (~200 MB) as soon as my application is launched. When I attempt to play the video in my viewDidLoad, breakpoints indicated that the view was added however the video did not show up…
Peter Kazazes
  • 3,600
  • 7
  • 31
  • 60
3
votes
2 answers

iOS Root View Controller's viewDidAppear: called while splash screen (Default.png) still on screen

In my iOS app I want to run a series of operations in my Root View Controller after it has already appeared on the screen. However, it seems that the iOS app is calling viewDidAppear while the splash screen (i.e. showing the Default.png image) is…
Jason
  • 14,517
  • 25
  • 92
  • 153
3
votes
1 answer

UITableView delegate methods being called before viewDidLoad()

in the UIViewController's viewDidLoad() there is a method being called for updating a class variable. Once I navigate to another view controller and come back to this one, UITableView's delegate methods are being called first where that class…
as diu
  • 1,010
  • 15
  • 31
3
votes
4 answers

Does defining functions inside viewdidload() save more memory versus defining them outside?

Since viewdidload() is only called once in the lifecycle of that instance of the UIViewController object, does that mean that this example below is a "bad practice" since setBackgroundColor(), a function that is only called once, is unnecesarrily…
youareawaitress
  • 387
  • 2
  • 17
3
votes
1 answer

Refresh view controller content on app entering foreground

I have an app with a tab bar that has a few tabs with user-generated content. When each view controller loads, the viewDidLoad method makes HTTP requests to a server to fetch data, then populates its view correspondingly. Once all the data is…
pmc255
  • 1,499
  • 2
  • 19
  • 31
3
votes
1 answer

calling viewdidload when using popViewController SWIFT

I have a navigation view controller and I am using popViewControllerAnimated(true) to show the view controller shown before. It works but I need to call the viewDidLoad of the before shown view controller to reload a table view. The viewDidLoad is…
Lenny1357
  • 748
  • 1
  • 13
  • 21
3
votes
0 answers

Screen orientation change calls unexpected viewDidLoad

I have an application with two view controllers, namely vc1 and vc2. I also have a navigation controller on top of them. I want vc1 to be in portrait orientation and vc2 to be in landscape right orientation. For this, I use the following code…
3
votes
0 answers

viewWillAppear and viewDidAppear called - viewDidLoad not

I have a ViewController that calls viewWillAppear and viewDidAppear without calling viewDidLoad. How can this be?
YogevSitton
  • 10,068
  • 11
  • 62
  • 95