私は、プロトタイプのセルから詳細ページ、通常の古いUIViewControllerにストーリーボードプッシュセグをリンクするUITableViewControllerを持っています。ストーリーボードでは、詳細ViewControllerに識別子があり、segueには最初の文字が小文字であることを除いて詳細識別子と同じ識別子があります。さらに、詳細ViewControllerには、クラスプルダウンで「カスタムクラス」(AttractionDetailViewController
)が選択されています。Objective-C、Storyboard:instantiateViewControllerWithIdentifierはnilを返します
動作しません。問題はinstantiateViewControllerWithIdentifier:@"AttractionDetails
がnil
を返すことです。
関連コード。まず、デバッガが一度も入力したことのない方法prepareForSegue
。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"attractionDetails"])
{
AttractionDetailViewController *attrDetailVC = [segue destinationViewController];
}
}
は、その代わりに、この方法に入る:それはもちろん例外をスロー
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//AttractionDetailViewController *attrDetailVC = [[AttractionDetailViewController alloc] init];
AttractionDetailViewController *attrDetailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"AttractionDetails"];
NSIndexPath *selIndexPath = [self.tableView indexPathForSelectedRow];
attrDetailVC.theAttraction = [attractions objectAtIndex:indexPath.row];
[self.navigationController pushViewController:attrDetailVC animated:YES];
}
nil
戻りinstantiateViewControllerWithIdentifier
ので。本当に興味深いのは、代わりにalloc init
行を使用すると動作しますが、画面はすべて黒です。
とにかく、これについて読んだことがあり、いくつかのことを試してみましたが、私はまだ窮地に瀕しています。誰にも何か提案はありますか?
うん、実際はそうです。これは私がチェックすると思っていなかったのは、まあ、私は何とか「自己」になったからです(ルートナビゲーションコントローラから3番目のビューです)。私はこれを代わりに試してみて、それはトリックをするようだ: 'UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@" MainStoryboard "バンドル:[NSBundle mainBundle];'。ありがとう! –