我对iPhone相当陌生。我有一个特殊的问题。我正在将视图控制器作为subView添加到当前视图。然后,我想从中推送一个新的视图控制器。问题是当我尝试做pushViewController时,它没有响应。
例如,在CurrentViewController中,我已将NewViewController的视图添加为subView
[self.view addSubView : NewViewController.view]
现在从NewViewController,单击一个按钮,我正在执行以下操作:
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
这里secondVC不会被压入堆栈。
如果使用过基于视图的应用程序,则必须使用此代码。
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
// [self.navigationController pushViewController:secondVC animated:YES];
[self presentModalViewController:secondVC animated:YES];
如果要在appln中使用导航控制器。首先,您必须在appln中添加导航控制器,然后才可以导航视图。
也许问题是方法称为pushViewController
而不是pushToViewController
。尝试
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
// don't forget release here
[secondVC release];