ストーリーボードを使用して非常にシンプルなアプリを作成しました (初めて)。
アプリは基本的に、Navigation Controller に埋め込まれた Table View Controller であり、画像を表示する View Controller につながります。しかし、行をクリックすると、Thread 1 SIGABRT エラーが発生します。ログは次のとおりです。
2013-09-03 22:37:16.669 FootballPlayers[7226:c07] * キャッチされない例外 'NSInternalInconsistencyException' が原因でアプリを終了します。理由: '-[UITableViewController loadView] が「PcV-xW-t12-view-xx8-ac- 4rU" nib を取得しましたが、UITableView を取得できませんでした。* First throw call stack: (0x1c94012 0x10d1e7e 0x1c93deb 0x245357 0xf6ff8 0xf7232 0xf74da 0x10e8e5 0x10e9cb 0x10ec76 0x10ed71 0x10f89b 0x10fe93 0xc4823f7 0x10fa88 0x46be63 0x45db99 0x45dc14 0xc5249 0xc54ed 0xacf5b3 0x1c53376 0x1c52e06 0x1c3aa82 0x1c39f44 0x1c39e1b 0x1bee7e3 0x1bee668 0x15ffc 0x226d 0x2195 0x1) libc++abi.dylib: terminate called throwing例外
これが TableViewController の実装です
#import "PlayersTableViewController.h"
@interface PlayersTableViewController ()
@end
@implementation PlayersTableViewController
NSMutableArray *players;
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
DisplayViewController *dvc = [segue destinationViewController];
NSIndexPath *path = [[self tableView] indexPathForSelectedRow];
[dvc setCurrentPlayer:[players objectAtIndex:[path row]]];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
players = [[NSMutableArray alloc] init];
Player *stevenGerrard = [[Player alloc] init];
[stevenGerrard setName:@"Steven Gerrard"];
[stevenGerrard setFileName:@"Steven Gerrard.jpg"];
[stevenGerrard setInformation:@"International Team : England, Club : Liverpool FC"];
[players addObject:stevenGerrard];
Player *cristianoRonaldo = [[Player alloc] init];
[cristianoRonaldo setName:@"Cristiano Ronaldo"];
[cristianoRonaldo setFileName:@"Cristiano Ronaldo.jpg"];
[cristianoRonaldo setInformation:@"International Team : Portugal, Club : Real Madrid"];
[players addObject:cristianoRonaldo];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#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 [players count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PlayerCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
Player *current = [players objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[current name]];
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:@[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
どうしたの ?!
ありがとうございました。