Trying my hand in a universal project, I would like to load vc by id from the storyboard. Is there a way to avoid explicitly checking the idiom when accessing the storyboard.
This ugly code works ....
UIStoryboard *storyboard; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil]; } else { storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; } UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"MyViewController"];
But yuck. The literal literal main storyboard is complex enough to look at (I donβt know why the project cannot save the main storyboard setting so that applications can say [UIStoryboard mainStoryboard];), but explicitly checking the idiom is too much of a bridge.
Is there any hidden intelligence (comparable to the suffix "@ 2x" that supports retina displays) that could clear this code?
danh
source share