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

标签 ios ipad

如何在二级上实现 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/

相关文章:

ios - ld : library not found for -lDoubleConversion React Native 0. 59

ios - 无法使用 Xcode 10.2+ 构建的通用(胖)框架编译模拟器构建

ios - 在测试中实例化 UIViewController

ios - 如何在 Swift 的 UITableView 底部显示 "pull-to-refresh"元素

iphone - 通过避免应用程序 10 分钟时间限制在后台连续工作

ios - Ionic Cordova 构建 ios 失败

ios - 将 mp4 视频保存到设备相机胶卷

ios - Xcode 10.3 中缺少模拟器

ios - 防止 iPad UIAlertView 在其外部单击时关闭?

iphone - iPad/iPhone硬件加速动画需要满足什么条件?