ViewController
をロードするためのボタンがありますTableViewController
。ボタンの背後にあるコードは次のとおりです。
- (IBAction)loadSearchView:(id)sender {
SearchTableViewController *searchVC = [[SearchTableViewController alloc] initWithStyle:UITableViewStylePlain];
[[self navigationController] pushViewController:searchVC animated:YES]; }
ロードするTableViewController
と、次のエラーでアプリがクラッシュします。
2013-02-21 15:22:19.460 MyMusicLibrary[4159:c07] -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: 認識されないセレクターがインスタンス 0x7aa0800 に送信されました 2013-02-21 15:22:19.462 MyMusicLibrary[4159:c07] * アプリの終了due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance 0x7aa0800' * First throw call stack: (0x14b5022 0xeb5cd6 0x14b6cbd 0x141bed0 0x141bcb2 0x3279 0xb2c54 0xb33ce 0x9ecbd 0xad6f1 0x56d21 0x14b6e42 0x1d86679 0x1d90579 0x1d154f7 0x1d173f6 0x1d16ad0 0x148999e 0x1420640 0x13ec4c6 0x13ebd84 0x13ebc9b 0x139e7d8 0x139e88a 0x18626 0x1fdd 0x1f05) 例外をスローして呼び出された終了
TableViewController のロード時に実行しようとしているコードは次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[[cell textLabel] setText:[NSString stringWithFormat:@"Cell %i", [indexPath row]]];
return cell;
}
numberOfSectionsInTableView と numberOfRowsInSection は次のように設定されます。
- (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 10;
}
ただし、これらが両方とも 0 に設定されている場合は、テーブル ビューが読み込まれます。誰でも助けることができますか?:)