gpt4 book ai didi

ios - 如何在二级上实现 SplitViewController。?

转载 作者:可可西里 更新时间:2023-11-01 06:16:55 26 4
gpt4 key购买 nike

如何在二级上实现 SplitViewController。

实际上我想要的是在登录后启动带有登录页面的应用程序。我需要 SplitViewController。

最佳答案

我就是这样做的。通过从窗口中删除第一个 viewContorller 并将其替换为 splitView

 splitViewController = [[SplitViewController alloc]init];
// remove the current view and replace with splitViewController
[theWindow addSubview:splitViewController.view];

// Transition handling
NSString *subtypeDirection;
switch ([[UIApplication sharedApplication] statusBarOrientation]) {
case UIDeviceOrientationPortrait:subtypeDirection = kCATransitionFromRight;break;
case UIDeviceOrientationPortraitUpsideDown:subtypeDirection = kCATransitionFromLeft;break;
case UIDeviceOrientationLandscapeLeft:subtypeDirection = kCATransitionFromTop;break;
case UIDeviceOrientationLandscapeRight:subtypeDirection = kCATransitionFromBottom;break;
default: NSLog(@"break at subType direction");break;
}

CATransition *animation = [CATransition animation];
[animation setDuration:.5];
[animation setType:kCATransitionPush];
[animation setSubtype:subtypeDirection];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToSplitView"];

[self.navigationController.view removeFromSuperview];

这里的大部分行都涉及过渡和处理轮换。

self 指的是第一个 ViewController 而 theWindow 指的是应用程序窗口。您可以通过以下方式获取它:[self superView];

关于ios - 如何在二级上实现 SplitViewController。?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7816670/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com