我在视图控制器中使用以下代码,我想让它呈现另一个名为“chooserViewController”modaly的视图控制器
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
{
[self presentModalViewController:chooserViewController animated:YES];
}
我收到编译错误而无法识别“chooserViewController”。我做错了吗?
更新
- (void)add:(id)sender
{
RoutineExerciseChooserViewController *routineExerciseChooserViewController = [[RoutineExerciseChooserViewController alloc] initWithNibName:@"RoutineExerciseChooserViewController" bundle: nil];
[self presentModalViewController:routineExerciseChooserViewController animated:YES];
[routineExerciseChooserViewController release];
}
答案 0 :(得分:1)
您需要创建chooserViewController
:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated {
ChooserViewController *chooserViewController = [[ChooserViewController alloc] initWithNibName:@"ChooserView" bundle: nil];
[self presentModalViewController:chooserViewController animated:YES];
[chooserViewController release];
}
如果您没有从笔尖加载,显然您将使用不同的方式创建chooserViewController
,但您必须采取一些措施来确保它存在,然后才能显示。