模态视图不起作用

问题描述

| 我在视图控制器中使用以下代码,并且希望它提供另一个名为\“ 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
,但是您必须做一些事情以确保它存在,然后才能显示出来。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...