0

我对 iPhone 还很陌生。我有一个特殊的问题。我正在将视图控制器作为子视图添加到当前视图。然后我想从中推送一个新的视图控制器。问题是当我尝试执行 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 不会被推入堆栈。

4

2 回答 2

1

如果您使用过基于视图的应用程序,则必须使用此代码。

  SecondViewController *secondVC = [SecondViewController   alloc]initWithNibName:@"SecondViewController" bundle:nil];
   // [self.navigationController pushViewController:secondVC animated:YES];

      [self presentModalViewController:secondVC animated:YES];

如果你想在你的应用程序中使用导航控制器。首先,您必须在 appln 中添加导航控制器,然后才能导航视图。

于 2010-06-04T14:23:46.020 回答
0

也许问题在于方法被称为pushViewControllernot pushToViewController。尝试

SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
// don't forget release here
[secondVC release];
于 2010-06-04T13:53:28.717 回答