关闭通过模态段显示的视图 [英] Closing a view displayed via a modal segue

查看:91
本文介绍了关闭通过模态段显示的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我手动调用segue(设置为模态)为了使用Storyboards在Xcode 4.2中显示一个登录表单,代码如下:

I'm manually invoking a segue (set as modal) in order to display a login form in Xcode 4.2 using Storyboards with the following line of code:

[self performSegueWithIdentifier:@"LoginSegue" sender:nil];

我可能缺少一些非常简单的东西,但是我找不到一种方法来以编程方式关闭

I'm probably missing something really simple, however I can't find a way to programmatically close the login view and return to the previous view.

视图是导航视图控制器的一部分,因此将segue类型设置为push允许我使用后退按钮发送回我的上一个屏幕,但在模态模式,我不完全确定如何实现这一点(例如按钮按下)

The view is part of a navigation view controller, so setting the segue type to "push" allows me to use the back button to send me back to my previous screen, but in "modal" mode, I'm not entirely sure how to achieve this (after button press, for example)

任何

推荐答案

如果您的部署目标是iOS 5.0或更高版本,请使用以下消息:

If your deployment target is iOS 5.0 or later, use this message:

[self dismissViewControllerAnimated:YES completion:nil];

或在Swift中:

self.dismissViewControllerAnimated(true, completion: nil)

是旧的,请使用此(已弃用)消息:

If your deployment target is older, use this (deprecated) message:

[self dismissModalViewControllerAnimated:YES];

这篇关于关闭通过模态段显示的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆