2012-04-05 7 views
21

ナビゲーションコントローラを使用しているXCode iPadプロジェクトがあります。私は、ナビゲーションスタックにUISplitViewControllerをプッシュするボタンを取得しようとしましたが、このエラーを得た:iOS:UISavitControllerにUISplitViewControllerをプッシュできません

Split View Controllers cannot be pushed to a Navigation Controller

はUISplitViewControllerはUINavigationControllerとうまく再生されない判明します。しかし、このボタンをクリックしたときにスプリットビューコントローラを表示する必要があります。これはどうすればいいですか?また、重要なのは、バック・ボタンを作成してユーザーをナビゲーション・コントローラーに戻す方法です。

答えて

28

SplitViewControllerを表示するには、setRootViewControllerを使用する必要があります。これは、SplitViewControllerがルートビューコントローラである必要があるためです。 Appleのドキュメントから

は:

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application's window. The panes of your split-view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface.

戻って取得するには、前のページに戻ってsetRootViewControllerを使用する必要があります。 iPhoneのアプリケーションをユニバーサルに変換したときにこの問題に遭遇し、iPhoneのナビゲーションコントローラとiPadのバージョンのsetRootViewControllerを使用して終了しました。 without a bit of fudgingをうまく動かすことができないので、少しばかりです。

+0

どのようにsetRootViewControllerを使用しますか? GoogleではそれがUIWindowのメソッドだと教えていますが、UIWindowインスタンスの場所を特定できません。 –

+2

あなたは、次のように、あなたのアプリケーションデリゲートからプロパティとしてそれを取得する必要があります:MyAppDelegate * appDelegate =(MyAppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate.window setRootViewController:shareSelectViewController];をクリックします。 – glenstorey

+0

ありがとうございます! –