Like many other developers out there, I've created iPhone projects that use a UITabBarController
as the root controller, with the tab views using UINavigationController
s to drill down from lists to detail views. And like many other developers out there, I need to migrate these apps to the iPad so they take advantage of the bigger screen (and more importantly, not forcing the user to use the ugly "doubling" visualization for iPhone-only apps).
Apple created the UISplitViewController
for this exact scenario... seemingly. I say seemingly because although I see it used in Settings, iPod, iTunes, and so on, none of those applications use UISplitViewController
inside a UITabBarController
, because it's not only documented as not working, but apps can crash if those two are forced into a shotgun marriage.
Consider a hypothetical iPhone application all about Animals. It has three tabs: "Categories" (where animals are categorized by some simple method -- perhaps we have a two-level hierarchy with categories like "Birds" and "Fish"), "Search" (which uses a standard UITableView
and a UISearchDisplayController
), and "Stories", which are stories about animals (perhaps there is a story about frogs, and another about computer nerd horses that turned into l33t unicorns).
While "Categories" and "Search" are two tabs that could be merged, it's n开发者_如何学运维ot clear that you could or should merge the list of animals with the stories about the animals. So while you might like to use a UISplitViewController on the iPad (with the search integrated in the "root", left, side of the split), how do you present the "Stories" view? Do you use a segmented controller? Top or Bottom? "Root" or "Detail" view of the split? Or perhaps you use a "home" screen (like WebMD's iPad app) which shows two buttons ("Categories" and "Stories") and then shows a split view for whichever the user taps? Or a toolbar at the top or bottom?
I tried looking at several other apps, including Settings, Mail, iPod, iTunes, Contacts, Maps and so on, but none of them present two "different" kinds of information in one application.
What's the general approach here? Are there any best practices? Any general patterns that the iPad programming community has adopted?
Or do I wait and cross my fingers that Apple somehow eventually allows UISplitViewController
to work without requiring it to be the "root"? (That might never happen!)
You could use the UISplitViewController
and have a UITabBarController
as the master view controller (the left side pane that is usually a list).
That way you could still use the tabs and drill down approaches until you read the detail view for each animal (using your analogy) and then display the detail page in the detail view controller (the right side pane).
This would work and isn't forbidden by Apple or the HIG.
That's my idea anyway :)
精彩评论