将帐户添加到“邮件”(首选项)时,您将获得一个模态视图,如下所示:
我的问题是,如何以编程方式复制此内容?换句话说,如何在呈现 View 上显示模式UIView?
这是我所拥有的:
import UIKit
class ViewController: UIViewController {
@IBAction func addCard(sender: AnyObject) {
var addContact : secondViewController = secondViewController()
self.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal
self.modalPresentationStyle = .CurrentContext // Display on top of current UIView
self.presentViewController(addContact, animated: true, completion: nil)
}
//Code goes on to do other unrelated things
此外,我还完成了以下操作:
预期的行为是,当按下UIBarButton“添加联系人”(成功触发以上代码中的
@IBAction func addCard(sender: AnyObject)
)时,secondViewController在主 View 上方显示为模态视图。当我运行上面的代码时,出现错误
"Use of undeclared type secondViewController"
我究竟做错了什么?
注意:这是对an earlier question的重新询问,其中我问了一个类似但略有不同的问题。我检查了meta,我认为还可以-我不想使原始问题的答案无效,因为这是在问一些稍有不同的问题。另外,如果有帮助,我在obj C中发现了一些similar问题。如何快速完成此操作?
最佳答案
试试这个 :)
@IBAction func addCard(sender: AnyObject) {
self.modalTransitionStyle = UIModalTransitionStyle.coverVertical
// Cover Vertical is necessary for CurrentContext
self.modalPresentationStyle = .currentContext
// Display on top of current UIView
self.present(secondViewController(), animated: true, completion: nil)
}
关于ios - 如何快速使用模态视图?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25223607/