ios - 当用户快速点击我的容器时,如何打开另一个 UIViewController?

标签 ios swift uiviewcontroller

我有一个 UIViewController,它包含一个容器,其中嵌入了另一个 UIViewController。我想在用户点击容器时显示第三个 UIViewController。

到目前为止,我设法做到了这一点:

@IBOutlet weak var requestDetails: UIView!  //my embedded container

override func viewDidLoad() {
    let gesture = UITapGestureRecognizer(target: self, action: "showRequest:")
    requestDetails.addGestureRecognizer(gesture)
}

func showRequest(sender:UITapGestureRecognizer){
    print("hi")    
}

现在,当用户点击容器时,我可以将 hi 打印到控制台。但我想在全屏上显示另一个名为 fullscreenViewController 的 UIViewController。我该怎么做?

最佳答案

这是快速版本:

presentViewController(fullScreenViewController, animated: true, completion: nil)

当然你可以从 Storyboard 中做到这一点:

enter image description here

例如,您只需按住 CTRL 并单击一个按钮,然后拖动到您要显示的 View Controller ,然后单击 show

希望对你有帮助

关于ios - 当用户快速点击我的容器时,如何打开另一个 UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35918341/

相关文章:

ios - XCODE 6 (6A313) 使用 Outlets 编译错误

ios - Magical Record 添加对象,不同上下文错误

ios - 限制 UITextField 的字符时,“完成”按钮不起作用

ios - 我该如何解决 Could not cast value of type 'UINavigationController'

ios - 为什么我的 UIBarButtonItem 不调用我的自定义函数?

ios - 关于在两个 MAC 中为 IOS 使用相同的分发配置文件

macos - OSX 状态菜单在 Swift 中不起作用

swift - 如何从 CLGeocoder geocodeAddressString() 中的完成处理程序更新列表中的地址

ios - 如果 View Controller 由于内存不足而被卸载,那么当它即将再次显示时,loadView 是否会再次被调用?

ios - iPhone 的 UIViewController 大小不正确