L'ajout de cellules à la vue de la table (UITableView) dans XCode

Je suis nouveau sur X-Code et ont simplement commencé à travailler sur ma première application. J'utilise les Storyboards. De la manette de Navigation de la scène, j'ai ajouté un MasterViewController avec deux cellules, ce qui conduit à deux DetailViewControllers (Detail1 & Détail 2).

  • Nombre de Colonnes = 1
  • Nombre de lignes dans les colonnes = 2

J'ai ajouté une Réutilisation de l'Indicateur pour les cellules dans les attributs de l'inspecteur, et fait le lien dans la table de montage séquentiel.

Mais quand je lance l'application, je ne vois que la première cellule x2.

Quand je regarde dans le MasterViewController.m je peux voir le code pour la première cellule, mais je ne comprends pas comment insérer la deuxième cellule, etc!

Je sais que la solution est facile et j'ai été à la recherche pour la réponse 3 jours maintenant, je me sens stupide, mais j'ai vraiment besoin d'aide maintenant,,

Quelqu'un peut-il m'aider à comprendre comment ajouter plus de cellules dans le code, et peut-être comprendre l'Affichage de la Table de Code un peu plus?

C'est le code pour l'affichage de la table jusqu'à présent:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//Return the number of rows in the section.
return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Formal";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

//Configure the cell...

return cell;
}

/*
//Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
//Return NO if you do not want the specified item to be editable.
return YES;
}
*/

/*
//Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
    //Delete the row from the data source
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath][withRowAnimation:UITableViewRowAnimationFade];
}   
else if (editingStyle == UITableViewCellEditingStyleInsert) {
    //Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}   
}
*/

/*
//Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
//Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
//Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Navigation logic may go here. Create and push another view controller.
/*
 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
 //...
 //Pass the selected object to the new view controller.
 [self.navigationController pushViewController:detailViewController animated:YES];
 */
}

@end

OriginalL'auteur ingenspor | 2012-06-02