Вопрос

I have an iPhone app that works and is getting used. I now want to upgrade this application to a Universal app. Taking that into consideration I've already made changes, like creating another MainWindow.xib for the iPad, which i've gotten to work. I've pretty much got the whole iPhone App working for the iPad. The next step I needed to take was to convert my Events Calendar to be a splitview. As far as I can tell, I'm don't need to change any of the logic in the two controllers I already have (CalendarViewController and CalendarDetailViewController).

That being said, what is the best way to make them work on a splitview? Is it possible to have the splitview use these two controllers (since a splitview has two controllers by default, a TableViewController and a ViewController)? Would I then need to create another appDelegate or something to pass all the right information back to the MainWindow.xib? Or am I going to need to create a new SplitViewController? and if so, how would I then combine all the logic from my two Calendar Controllers?

Any help would be greatly appreciated!!

Это было полезно?

Решение

Assuming you are using StoryBoard: drag a SplitViewController into the iPad StoryBoard. Also be sure your two desired UIViewControllers are in there. Control-click on the SplitViewController and drag over to each UIViewController and select you how want it set.

Другие советы

I know it's a bit late to answer this question but if someone needs... You don´t need another appDelegate, you just need to check (in appDelegate) whether your device is an iPad, and then set an array of view Controllers with the MasterVC and the DetailVC. Otherwise you will set your rootViewController as you are doing now in the iPhone app.

It would be something similar to that:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[...]

YourMasterVC *mvc =
[[YourMasterVC alloc] initWithStyle:UITableViewStylePlain];

UINavigationController *masterNav =
[[UINavigationController alloc] initWithRootViewController:mvc];

YourDetailVC *dvc = [[YourDetailVC alloc] init];
cvc.detailViewController = dvc;

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {

    // On iPad
    UINavigationController *detailNav =
    [[UINavigationController alloc] initWithRootViewController:dvc];

    UISplitViewController *svc = [[UISplitViewController alloc] init];

    svc.delegate = wvc;

    svc.viewControllers = @[masterNav, detailNav];

    self.window.rootViewController = svc;
} else {
    // On iPhone
    self.window.rootViewController = masterNav;
}

[...]

}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top