问题描述
|
我在视图控制器中使用以下代码,并且希望它提供另一个名为\“ chooserViewController \”模态的视图控制器
- (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];
}
解决方法
您需要创建
chooserViewController
:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated {
ChooserViewController *chooserViewController = [[ChooserViewController alloc] initWithNibName:@\"ChooserView\" bundle: nil];
[self presentModalViewController:chooserViewController animated:YES];
[chooserViewController release];
}
如果您不是从笔尖加载,显然您会使用另一种方式来创建chooserViewController
,但是您必须做一些事情以确保它存在,然后才能显示出来。