如何设置 UIButton 以转到上一个屏幕



我有一个可以从任何其他屏幕访问的帮助屏幕。唯一的按钮是一个"后退"箭头。现在它总是回到主屏幕。但是,我需要它回到之前的屏幕。我已经通过stackoverflow和google进行了搜索,但没有运气。

编辑我现在使用的代码片段:

appViewController *homeView = [[appViewController alloc] initWithNibName:nil bundle:nil];
homeView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:homeView animated:YES];

从现在显示的模态视图控制器中,在单击主页按钮时使其自行关闭:

- (void)buttonClicked
{
    [self dismissModalViewControllerAnimated:YES];
}

在按钮上单击您可以使用。

[self.navigationController popViewControllerAnimated:YES];

也许此链接将帮助您: 如何从iPhone中的相机视图导航上一个屏幕?它与导航以及如何删除最后一个屏幕有关。

或者在按钮的单击事件中使用它。创建要打开的视图控制器的实例

          EnterNameController *newEnterNameController = [[EnterNameController alloc]   initWithNibName:@"EnterName" bundle:[NSBundle mainBundle]];
          [[self navigationController] pushViewController:newEnterNameController animated:YES];

最新更新