-(IBAction) btnReturn:(id) sender{
firstView * firstview =[[firstView alloc]initWithNibName:@"firstView" bundle:nil];
[self.view pushViewController:firstview animated:NO];
}
使用previsly代码我看到第一个视图但导航控件增量。我和导航起点一样来了。有什么帮助吗?
答案 0 :(得分:4)
pushViewController:animated:
将添加到导航堆栈;您希望popViewControllerAnimated:
返回堆栈中的一个视图。
如果要返回第一个(根)视图控制器,则需要popToRootViewControllerAnimated:
。
答案 1 :(得分:0)
在上面的代码中,您正在self.view
(firstView
上推送控制器,我将其视为控制器,因为您使用initWithNibName
创建它:方法,但你应该适当的命名约定,以避免混淆。)但视图没有任何这样的方法pushViewController
:.相反,如果您在导航堆栈中确实拥有self
(您在其中使用此IBAction
的控制器),则可以使用。
[self.navigationController pushViewController:firstview animated:NO];
要从导航堆栈弹出控制器,请按照建议的 @gregheo 进行操作。
答案 2 :(得分:0)
请尝试使用popViewControllerAnimated
:
- (IBAction)btnReturn:(id)sender
{
[self.navigationController popViewControllerAnimated:NO]; // Or Yes if you would like to have an animation.
}