我一直认为可以将类作为方法参数传递,但我在实现这个概念时遇到了困难.现在我有点像:
- (id)navControllerFromView:(Class *)viewControllerClass
title:(NSString *)title
imageName:(NSString *)imageName
{
viewControllerClass *viewController = [[viewControllerClass alloc] init];
UINavigationController *thisNavController =
[[UINavigationController alloc] initWithRootViewController: viewController];
thisNavController.tabBarItem = [[UITabBarItem alloc]
initWithTitle: title
image: [UIImage imageNamed: imageName]
tag: 3];
return thisNavController;
}
我这样称呼它:
rootNavController = [ self navControllerFromView:RootViewController
title:@"Contact"
imageName:@"my_info.png"
];
这张照片怎么了?