Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Viewcontroller未被推送到堆栈_Iphone_Uinavigationcontroller_Addsubview - Fatal编程技术网

Iphone Viewcontroller未被推送到堆栈

Iphone Viewcontroller未被推送到堆栈,iphone,uinavigationcontroller,addsubview,Iphone,Uinavigationcontroller,Addsubview,我对iPhone相当陌生。我有一个特殊的问题。我正在将视图控制器作为子视图添加到当前视图中。然后我想从中推出一个新的视图控制器。问题是当我尝试执行pushViewController时,它没有响应 例如,在CurrentViewController中,我将NewViewController的视图添加为子视图 [self.view addSubView : NewViewController.view] 现在,在NewViewController中,单击一个按钮,我将执行以下操作: Second

我对iPhone相当陌生。我有一个特殊的问题。我正在将视图控制器作为子视图添加到当前视图中。然后我想从中推出一个新的视图控制器。问题是当我尝试执行pushViewController时,它没有响应

例如,在CurrentViewController中,我将NewViewController的视图添加为子视图

[self.view addSubView : NewViewController.view]
现在,在NewViewController中,单击一个按钮,我将执行以下操作:

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

在这里,第二个VC不会被推到堆栈中。

可能问题是该方法被称为
pushViewController
而不是
pushToViewController
。试一试

SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
// don't forget release here
[secondVC release];

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

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

      [self presentModalViewController:secondVC animated:YES];

如果要在应用程序中使用导航控制器。首先,您必须在应用程序中添加导航控制器,然后才可以导航视图。

子视图甚至会有导航控制器吗?@Jayashree。您使用过视图控制器appln还是基于导航的应用程序?@Pugal:CurrentViewController和NewViewController是基于视图的,SecondViewController是基于导航的应用程序Hi。不,那只是打字错误。我会改正的。但是有没有其他的想法呢??