获取storyboard箭头指向的根控制器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
* 通过名称获取storyboard箭头指向的根控制器
*
* @param sbName storyboard名字
*
* @return storyboard instantiateInitialViewController
*/
- (id)viewControllerWithSBName:(NSString*)sbName {
//获取程序的名字
NSDictionary* info = [[NSBundle mainBundle] infoDictionary];
NSString* prodName = [info objectForKey:@"CFBundleExecutable"];
NSString* sbPath = [NSString stringWithFormat:@"%@/%@/", prodName, sbName];
// NSLog(@"%@", [[UIStoryboard
// storyboardWithName:sbName
// bundle:[[NSBundle alloc]
// initWithPath:sbPath]]
// instantiateInitialViewController]);
return
[[UIStoryboard storyboardWithName:sbName
bundle:[[NSBundle alloc] initWithPath:sbPath]]
instantiateInitialViewController];
}