Beginning Storyboards in iOS 5 Part 1

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Re: Beginning Storyboards in iOS 5 Part 1

Postby gfresh » Sun Oct 16, 2011 10:59 pm

That was exactly what the problem was related to. I had typed "Player Cell" instead of "PlayerCell". I am extremely impressed with the amount of support you offer for your tutorials and to blog readers. Because of this, I'm definitely going to buy your book because it's obvious the authors care about their readers. I have the Cocos2D book, looks like it's time to add iOS5 to the collection as well. :D
gfresh
Baby Hacker
 
Posts: 8
Joined: Sun Oct 16, 2011 12:29 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Storyboards in iOS 5 Part 1

Postby Hollance » Sun Oct 16, 2011 11:56 pm

Cool, gfresh. We're here to help. :-)
Like card games? Play my new game Mahjong Cards for iPad.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4745
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 660 times

Re: Beginning Storyboards in iOS 5 Part 1

Postby Cal » Mon Oct 17, 2011 3:55 am

Great tutorial. Thank you very much.
Cal
Hacker
 
Posts: 13
Joined: Thu Jul 14, 2011 12:06 am
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Storyboards in iOS 5 Part 1

Postby azamsharp » Mon Oct 17, 2011 8:10 pm

In the following code why did you use delegates when you could simply dimiss the controller from right within the controller.

Code: Select all
-(IBAction)cancelButtonAction:(id)sender
{
    NSLog(@"cancelButtonAction");
   
    [self dismissViewControllerAnimated:YES completion:nil];  // this also works
   
    //[self.delegate playerDetailsViewControllerDidCancel:self]; // why use delegates
}

-(IBAction)doneButtonAction:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
   
    //[self.delegate playerDetailsViewControllerDidSave:self];
}


Another question is that why do you add the new player at a particular index instead of just reloading the tableView data:

Instead of the following:

Code: Select all
- (void)playerDetailsViewController: (PlayerDetailsViewController *)controller
didAddPlayer:(Player *)player
{
[self.players addObject:player]; NSIndexPath *indexPath =
[NSIndexPath indexPathForRow:[self.players count] - 1 inSection:0];
[self.tableView insertRowsAtIndexPaths: [NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic]; [self dismissViewControllerAnimated:YES completion:nil];
}


We can do this:

Code: Select all
-(void) playerDetailsViewController:(PlayerDetailsViewController *)controller didAddPlayer:(Player *)player
{
    [self.players addObject:player];
   
    [self.tableView reloadData];
   
    [self dismissViewControllerAnimated:YES completion:nil];
}


Maybe reloadData is not good for performance!
azamsharp
Baby Hacker
 
Posts: 5
Joined: Thu May 12, 2011 2:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Storyboards in iOS 5 Part 1

Postby Hollance » Mon Oct 17, 2011 8:44 pm

azamsharp wrote:In the following code why did you use delegates when you could simply dimiss the controller from right within the controller.

You are correct that in this case using a delegate isn't strictly necessary. Most of the time, however, you have data to send back to the presenting view controller and I wanted to drive home the point that delegates are the way to do that. ;-)
Like card games? Play my new game Mahjong Cards for iPad.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4745
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 660 times

Re: Beginning Storyboards in iOS 5 Part 1

Postby Hollance » Mon Oct 17, 2011 8:46 pm

azamsharp wrote:Another question is that why do you add the new player at a particular index instead of just reloading the tableView data:

Because it gives us a nice animation. ;-) You can't really see that very well because there is still another screen on top when the new row is inserted, but personally I prefer to use the insert/deleteRows methods wherever I can. Doing a [self.tableView reloadData] would also work, of course, but that doesn't update the table with an animation.
Like card games? Play my new game Mahjong Cards for iPad.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4745
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 660 times

Re: Beginning Storyboards in iOS 5 Part 1

Postby jpappas » Mon Oct 17, 2011 10:21 pm

This is very sweet! I'd love to adapt my current app-in-progress to use Storyboards rather than continuing on with the iOS 4 way of doing it... any tips on doing so? Can one suck the .xib file contents into views in the Storyboard?

Janene
jpappas
Baby Hacker
 
Posts: 6
Joined: Thu Oct 13, 2011 12:52 am
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Storyboards in iOS 5 Part 1

Postby Hollance » Mon Oct 17, 2011 10:41 pm

jpappas wrote:Can one suck the .xib file contents into views in the Storyboard?

There are some tips in the second chapter that is only in the ebook, but you can create a new view controller in the storyboard, remove its view, and copy-paste the contents of your xib into the view controller. You may need to re-connect things, though.
Like card games? Play my new game Mahjong Cards for iPad.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4745
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 660 times

Re: Beginning Storyboards in iOS 5 Part 1

Postby jpappas » Mon Oct 17, 2011 10:48 pm

Hollance wrote:There are some tips in the second chapter that is only in the ebook, but you can create a new view controller in the storyboard, remove its view, and copy-paste the contents of your xib into the view controller. You may need to re-connect things, though.


I had my mouse hovering over the Buy Now button... guess I'll press it :D Thanks!
jpappas
Baby Hacker
 
Posts: 6
Joined: Thu Oct 13, 2011 12:52 am
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Storyboards in iOS 5 Part 1

Postby nameghino » Mon Oct 17, 2011 11:59 pm

I know this doesn't relate to Storyboards per se, but, following the tutorial, I realised that in the Player class there are no ivars.
I tried a bit of debugging but found out that I cannot see the contents of the Player object using the inspector.

Any ideas on how I can view them?
A tip on what to search for or pointers to docs would be great too, given that I exhausted my google-fu and couldn't produce a good search query :(
nameghino
n00b
 
Posts: 3
Joined: Mon Oct 17, 2011 11:50 pm
Has thanked: 0 time
Been thanked: 0 time

PreviousNext

Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests