您可以尝试自定义转场,根据这个帖子hidden-a-segue-on-login-process。
或者,如果您迫切希望在拆分视图控制器加载之前显示登录信息,请尝试以下几行...
在主故事板上创建您的登录屏幕,例如,作为UIViewController
. 确保它是初始场景(检查Is Initial View Controller)。
在情节提要上,从您的登录类创建一个新的 segue 到原始的 SplitViewController。给它一个标识符 ' Load SplitViewController
' 和一个我们将调用的 segue 自定义类名FullyReplaceSegue
。
在您的登录类 .m 文件中,添加用户登录后要调用的代码:
[self performSegueWithIdentifier:@"Load SplitViewController" sender:self];
UIStoryboardSegue
根据上面的名称创建新的 segue 类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