ビューコントローラコンテナライブラリをメールメールクライアントに追加しようとしています。アイデアは、ビューコントローラコンテナということです presents its child view controllers in two layers. It provides functionality for sliding the top view to reveal the views underneath it.
ライブラリの説明では、これは子controllerViewをその親にアタッチするための推奨される方法です。
if (![self.slidingViewController.underLeftViewController
isKindOfClass:[MenuViewController class]]) {
self.slidingViewController.underLeftViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
}
ここで、slidingViewControllerはthe top-level instance of the view controller container. With this instance, you can set the view controllers underneath the top view and add panning.
ストーリーボードではなく、xibファイルを使用しています。代わりに私のコードは次のようになりました:
if (![self.slidingViewController.underLeftViewController
isKindOfClass:[MenuViewController class]]) {
self.slidingViewController.underLeftViewController =
[[MenuViewController alloc] initWithNibName:@"Menu" bundle:nil];
}
しかし、そのコードを使用しています。このエラーが発生します。
-[__NSArrayM insertObject:atIndex:]: object cannot be nil
これは、次のことを実行しているslidingViewControllerにトレースできます。
[self.view insertSubview:_underTopViewController.view atIndex:0];
ドキュメントを見ると..instantiateViewControllerWithIdentifierとinitWithNibNameには違いがあることがわかります。前者は常にオブジェクトを返しますが、後者は..のみをロードしますthe first time the view controller’s view is accessed
。
質問:そのビューが訪問されたかどうかに関係なく、initWithNibNameがロードされたviewcontrollerオブジェクトを返すようにするにはどうすればよいですか..instantiateViewControllerWithIdentifierと同様ですか?