この投稿hide-a-segue-on-login-processに従って、カスタム セグエを試すことができます。
または、Split View Controller が読み込まれる前にログイン画面を表示したい場合は、次の行に沿って何かを試してください...
のサブクラスなどとして、メインのストーリーボードにログイン画面を作成しますUIViewController
。それが最初のシーンであることを確認します ( Is Initial View Controllerをチェックします)。
ストーリーボードで、ログイン クラスから元の SplitViewController への新しいセグエを作成します。識別子 ' Load SplitViewController
' と、 と呼ぶセグエ カスタム クラス名を付けますFullyReplaceSegue
。
ログイン クラス .m ファイルに、ユーザーがログインしたときに呼び出されるコードを追加します。
[self performSegueWithIdentifier:@"Load SplitViewController" sender:self];
に基づいて新しいセグエ クラスを作成し、上記のようUIStoryboardSegue
に名前を付けFullyReplaceSegue
ます。
.h ファイル
#import <UIKit/UIKit.h>
@interface : UIStoryboardSegue
@end
.m ファイル
#import "FullyReplaceSegue.h"
@implementation FullyReplaceSegue
- (void)perform
{
UIViewController *dest = (UIViewController *) super.destinationViewController;
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.rootViewController = dest;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UISplitViewController *splitViewController = (UISplitViewController *)dest; // assumes we're transitioning to a UISplitViewController!
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
}
}
@end