我希望能够从不同的类打开 ViewController。所以我可以简单地调用它来在我需要的地方打开一个视图。
所以我在保存代码的类中有这个设置:
+ (void)openCalcView: (NSString *)nameOfView {
UIViewController *controller;
if ([nameOfView isEqualToString:@"Tax"]) {
controller = [[TAXViewController alloc]initWithNibName:@"TAXViewController" bundle:nil];
}else if ([nameOfView isEqualToString:@"Rent"]){
controller = [[RENTViewController alloc]initWithNibName:@"RENTViewController" bundle:nil];
}
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:controller animated:YES completion:nil];
[controller release];
}
但是[self presentViewController:controller animated:YES completion:nil];
给了我一个警告:
Class method '+presentViewController:animated:completion:' not found (return type defaults to 'id')
我可以NSLog
从任何类中调用像这样的简单事物。但这不起作用。