我是新来的X代码,刚开始工作我的第一个应用程序。我正在使用故事板。在导航控制器场景中,我添加了一个带有两个单元的MasterViewController,这导致了两个DetailViewControllers(Detail1 & Detail 2)。在= 2 在XCode中添加单元格到表格视图(UITableView)
我添加了一个复用指示器用于在属性检查员的细胞,并取得在故事板中的连接柱
- 列数= 1
- 的行数。
但是当我运行该应用程序时,我只能看到第一个单元格x2。
当我查看MasterViewController.m时,我可以看到第一个单元的代码,但我不明白如何插入第二个单元格等!
我知道解决的办法是容易的,我一直在寻找的答案为3天,我觉得自己很蠢,但我真的需要一些帮助,现在,,
有人可以帮助我了解如何添加更多的细胞在代码中,也许可以更多地理解表视图代码?
这是表视图到目前为止的代码:
#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
这帮助我在路上了很多,还是花了一些时间来弄清楚这一切了,但现在我懂了。 :) – ingenspor
@KristofferBilek考虑如果它帮助你,我的答案upvoting。谢谢! –
对不起,我也是这个地方新来的。我试过了,但是我没有足够的声望点去做。也许我应该将新的信息添加到您的答案中,而不是将其作为新答案发布。 hmm – ingenspor