已知为iOS5和Storyboards更新MGSplitViewController的工作? [英] Known effort to update MGSplitViewController for iOS5 and Storyboards?

查看:86
本文介绍了已知为iOS5和Storyboards更新MGSplitViewController的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款需要隐藏/显示分割视图主控制器的iPad应用程序。

I'm working on an iPad app that will need to hide/show the master controller of a split view.

相关SO答案注释Matt Gemmell的 MGSplitViewController

Related SO answers note Matt Gemmell's MGSplitViewController:

  • How to hide master view in UiSplitviewcontroller in ipad
  • How do I hide the master part of a UISplitViewController programatically?
  • Integrate MGSplitViewController in Universal App
  • MGSplitViewController using Storyboards

MGSplitViewController非常完美 - 甚至提供了一种调整主从视图比例的方法。

MGSplitViewController would be perfect - even providing a way to adjust the ratio of master-to-detail views.

太棒了!除了它与使用故事板和ARC的最新Xcode不太搭配。

Fantastic! Except it doesn't play nice with the latest Xcode using storyboards and ARC.

我看到拉动请求(从9个月前开始)转换为针对iOS4的ARC 但仍然需要做一些工作才能使故事板友好。

I see a pull request (from 9 months ago) to convert to ARC for iOS4 but that still leaves it needing some work to be storyboard friendly.

有没有人知道在最新的iOS开发环境中更新这个开源宝石的持续努力才能正常运行?

Does anyone know of ongoing effort to update this jewel of open source to behave properly in the latest iOS development environment?

如果不这样做,例子/如何将它集成到Xcode故事板/ iOS5项目的教程将非常有用。

Failing that, examples/tutorials of how to integrate it into an Xcode storyboard/iOS5 project would be very useful.

推荐答案

我能够解决故事板问题。我有一个带有主要详细故事板设置的通用应用程序,因此我将它们全部留在原位并将应用程序的初始化更改为不使用故事板,而是以编程方式将其设置在我的applicationDidFinishLaunching中:

I was able to work around the storyboard issue. I had a universal app with master detail storyboard setup so I left them all in place and changed the initialization of the app to not use storyboards and instead programmatically set it up in my applicationDidFinishLaunching like so:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];

    self.masterController = [storyboard instantiateViewControllerWithIdentifier:@"masterController"];
    self.detailController = [storyboard instantiateViewControllerWithIdentifier:@"detailController"];

    self.splitViewController = [[MGSplitViewController alloc] init];
    self.splitViewController.masterViewController = self.masterController;
    self.splitViewController.detailViewController = self.detailController;
    ACALandingVC* landingVC = [self.detailController.childViewControllers objectAtIndex:0];
    landingVC.splitController = self.splitViewController;
    self.splitViewController.delegate = landingVC;

    //self.splitViewController.splitWidth = 5;
    self.splitViewController.allowsDraggingDivider = YES;
    self.splitViewController.dividerStyle = MGSplitViewDividerStylePaneSplitter;
    self.splitViewController.splitPosition = 350;
    self.splitViewController.splitWidth = 10;


    self.window.rootViewController = self.splitViewController;
}
else {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
    UITabBarController* firstVC = [storyboard instantiateInitialViewController];
    self.window.rootViewController = firstVC;
    [[UINavigationBar appearance] setTintColor:[UIColor lightGrayColor]];
}

[self.window makeKeyAndVisible];

我的AppDelegate.h看起来像:

My AppDelegate.h looks like:

@class MGSplitViewController;

@interface ACAAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, strong) MGSplitViewController* splitViewController;
@property (nonatomic, strong) UITabBarController* masterController;
@property (nonatomic, strong) UINavigationController* detailController;

@end

这篇关于已知为iOS5和Storyboards更新MGSplitViewController的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆