OGeek|极客世界-中国程序员成长平台

标题: ios - 将取消 UIButton 添加到导航 Controller [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 03:32
标题: ios - 将取消 UIButton 添加到导航 Controller

我正在使用 Storyboard ,我在 View Controller 中添加了一个导航栏,我在导航栏中添加了两个栏按钮(在 Storyboard 中不是代码),一个是“保存”按钮,另一个是“取消”按钮。

现在我希望当我按下取消按钮时,已经查看过的 Controller 消失并且前一个 View Controller 显示出来。我应该在取消按钮的操作方法中包含什么代码:

- (IBAction)cancelid)sender 
{
    // what code should be written here ?
}



Best Answer-推荐答案


这首先取决于您如何呈现 View Controller 。如果您以模态方式呈现它,那么您将使用它:

[self dismissViewControllerAnimated:YES completion:nil];

但是,如果你通过导航 Controller 推送到当前 View Controller ,那么你会使用这个:

[self.navigationController popViewControllerAnimated:YES];

关于ios - 将取消 UIButton 添加到导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18261738/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4