2

I have an app with a first view then it displays two views in an UITabBarViewController.

Unhappily, it seems the ViewDidLoad method is not called in my two views linked by the Tab Bar. It has to display a title for example, action which is not done.

Here is a photo to illustrate my current work.

http://i41.tinypic.com/2duftz5.jpg

Rob
  • 415,655
  • 72
  • 787
  • 1,044
GoldXApp
  • 2,397
  • 3
  • 17
  • 26

1 Answers1

2

A couple of thoughts:

  1. You say ViewDidLoad. This is case sensitive and should be viewDidLoad. Or was that just a typo in the question.

  2. Make sure your child scenes have the appropriate view controller. If you select the view controller in IB, you should see something like the following in the Identity inspector:

    enter image description here

    If it looks like:

    enter image description here

    then that means that you may have neglected to specify the view controller subclass.

  3. You've got a weird set of segues from your tab bar controller to your child scenes; it's hard to tell what's going on there or why you've done that, but I'd get rid of those extra push segues. Instead of that mess of segues, it should look something like:

    tab bar controller

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • 2. In fact, I created two others segues to use the "prepareForSegue" method (to transfer data from View Controller to Item 1 & Item 2) where we have to name the segue. With the type of segue present in your image (between Tab Bar Controller and Item 1 & 2), you can't name the segue and so, you can't use "prepareForSegue". Finally, in deleting two segues to copy your image, nothing changes and I don't have any title on Item1 and Item2. Title are displayed by self.title=@"Drinks" method in viewDidLoad method of Item1 for example. – GoldXApp Aug 04 '13 at 17:48
  • 1. It was just a typo question. It is "viewDidLoad" which is present in my code. – GoldXApp Aug 04 '13 at 17:53
  • @GoldXApp I'd suggest you double check to make sure you've specified the view controller subclass in the identity inspector (see my revised answer). In terms of `prepareForSegue` in tab bar controller, you probably shouldn't be relying on `prepareForSegue`, but rather actually write a `UITabBarController` subclass, and handle the [`didSelectViewController`](http://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITabBarControllerDelegate/tabBarController:didSelectViewController:) method. – Rob Aug 04 '13 at 17:59
  • About new 2. : It's OK for the subclass name. This part is OK I think cause I tested the project with a direct link between ViewController and ViewController - Item1 (without Tab Bar). – GoldXApp Aug 04 '13 at 17:59
  • @GoldXApp let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34801/discussion-between-rob-and-goldxapp) – Rob Aug 04 '13 at 18:02