Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding cells to table view (UITableView) in XCode
    primarykey
    data
    text
    <p>I'm new to X-Code and have just started working on my first app. I'm using Storyboards. To the Navigation Controller scene I've added a MasterViewController with two cells, which leads to two DetailViewControllers (Detail1 &amp; Detail 2).</p> <ul> <li>Number of Columns = 1</li> <li>Number of rows in columns = 2</li> </ul> <p>I've added a Reuse Indicator for the cells in the attributes inspector, and made the connection in the storyboard.</p> <p>But when I run the app, I can only see the first cell x2.</p> <p>When I look in the MasterViewController.m I can see the code for the first cell, but I don't understand how to insert the second cell etc!</p> <p>I know the solution is easy and I've been looking for the answer for 3 days now, I feel stupid but I really need some help now,,</p> <p>Can someone help me understand how to add more cells in the code, and maybe understand the Table View Code a bit more?</p> <p>This is the code for the table view so far:</p> <pre><code>#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. /* &lt;#DetailViewController#&gt; *detailViewController = [[&lt;#DetailViewController#&gt; alloc] initWithNibName:@"&lt;#Nib name#&gt;" bundle:nil]; // ... // Pass the selected object to the new view controller. [self.navigationController pushViewController:detailViewController animated:YES]; */ } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload