Photo

Chapter 5: Problem With Storyboard Implementation Of Drinkmixer


  • Please log in to reply
5 replies to this topic

#1 AntonEsterhuyse

AntonEsterhuyse

    New Member

  • Members
  • Pip
  • 2 posts

Posted 04 January 2012 - 06:43 AM

Dear Fellow Head-First Fans!

I am trying to implement the DrinkMixer application using storyboard (xcode 4.2), however I am stuck with the of the sub-classing of the drink detail view controller to create the add drink detail view controller. initWithNibName needs to be replaced with instantiateViewControllerWithIdentifier in order to achieve the instantiation of the sub-classed view controller. However in this case, the viewDidLoad function of the subclass is never called (instead the viewDidLoad function of the superclass is called). I looked all over the internet, but cannot find a solution for this.

Please provide some insight into this problem

Regards
Anton

#2 bohanl

bohanl

    New Member

  • Members
  • Pip
  • 1 posts

Posted 12 September 2012 - 08:47 PM

Hi Anton,

I'm getting the same problem. Have you figured out a solution for this?

Thanks,
Bohan

Dear Fellow Head-First Fans!

I am trying to implement the DrinkMixer application using storyboard (xcode 4.2), however I am stuck with the of the sub-classing of the drink detail view controller to create the add drink detail view controller. initWithNibName needs to be replaced with instantiateViewControllerWithIdentifier in order to achieve the instantiation of the sub-classed view controller. However in this case, the viewDidLoad function of the subclass is never called (instead the viewDidLoad function of the superclass is called). I looked all over the internet, but cannot find a solution for this.

Please provide some insight into this problem

Regards
Anton



#3 AntonEsterhuyse

AntonEsterhuyse

    New Member

  • Members
  • Pip
  • 2 posts

Posted 12 September 2012 - 10:29 PM

Hi Bohan

No, I have not found the solution to this problem. Before now, it seemed like I was the only person experiencing this problem. It might be something trivial that we missed. I gave up the book due to this problem. Please let me know if you find a solution. My e-mail is anton.esterhuyse@gmail.com

Cheers
Anton

#4 FrankieR

FrankieR

    New Member

  • Members
  • Pip
  • 1 posts

Posted 15 October 2012 - 07:00 AM

Hi all, I was having the same problem and worked thru it. Here's what I did to get a working DrinkMixer app using storyboards (Xcode 4.5.1) after starting with the Master-Detail application template.

In the DrinkMixerMasterViewController.m (implementation file) I added the following -

In the viewDidLoad method I added:
// get the Drink Directions plist
NSString *path = [[NSBundle mainBundle] pathForResource:@"DrinkDirections" ofType:@"plist"];
drinks_ = [[NSMutableArray alloc] initWithContentsOfFile:path];

In the tableView:cellForRowAtIndexPath method I added -
// puts content in the cell (drink names)
cell.textLabel.text = [[self.drinks objectAtIndex:indexPath.row] objectForKey:NAME_KEY];

In the prepareForSegue method I added: (this is where you actually pass the info to the detail view)
if ([[segue identifier] isEqualToString:@"showDetail"]) {

NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

// create instance of detail view controller and set it to the segue
DrinkMixerDetailViewController *dvc = [segue destinationViewController];
dvc.drink = [self.drinks objectAtIndex:indexPath.row];

// Used to make sure i was getting the right drink/dictionary
// NSLog(@"%@",dvc.drink);

//set field text information from plist
dvc.nameTextField.text = [[self.drinks objectAtIndex:indexPath.row ] objectForKey:NAME_KEY];
dvc.ingredientsTextView.text = [[self.drinks objectAtIndex:indexPath.row] objectForKey:INGREDIENTS_KEY];
dvc.directionsView.text = [[self.drinks objectAtIndex:indexPath.row] objectForKey:DIRECTIONS_KEY];
}

Then, in the DrinkMixerDetailViewController.m (implementation file) I added:

In the configureView method:
self.nameTextField.text = [self.drink objectForKey:NAME_KEY];
self.ingredientsTextView.text = [self.drink objectForKey:INGREDIENTS_KEY];
self.directionsView.text = [self.drink objectForKey:DIRECTIONS_KEY];


Hope this helps.

#5 Emmalina

Emmalina

    New Member

  • Members
  • Pip
  • 2 posts

Posted 04 March 2014 - 03:05 AM

2 years later, I run into the exactly same problem with Xcode 5.01. I searched online and no clear solution. In order to continue the book, I copied and pasted the "DetailViewController" in storyboard, and named the new my subclass. When creating the subclass instance, the instantiateViewControllerWithIdentifier place, I put the subclass name, and it works. It is ugly, but so far it seems the only solution.

#6 Алексей Цымлов

Алексей Цымлов

    New Member

  • Members
  • Pip
  • 1 posts

Posted 25 May 2014 - 08:15 AM

Hi all.

It works. Thanks!

Regards
Alexey

2 years later, I run into the exactly same problem with Xcode 5.01. I searched online and no clear solution. In order to continue the book, I copied and pasted the "DetailViewController" in storyboard, and named the new my subclass. When creating the subclass instance, the instantiateViewControllerWithIdentifier place, I put the subclass name, and it works. It is ugly, but so far it seems the only solution.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

"