• <small id='7hEDo'></small><noframes id='7hEDo'>

    <i id='7hEDo'><tr id='7hEDo'><dt id='7hEDo'><q id='7hEDo'><span id='7hEDo'><b id='7hEDo'><form id='7hEDo'><ins id='7hEDo'></ins><ul id='7hEDo'></ul><sub id='7hEDo'></sub></form><legend id='7hEDo'></legend><bdo id='7hEDo'><pre id='7hEDo'><center id='7hEDo'></center></pre></bdo></b><th id='7hEDo'></th></span></q></dt></tr></i><div id='7hEDo'><tfoot id='7hEDo'></tfoot><dl id='7hEDo'><fieldset id='7hEDo'></fieldset></dl></div>
  • <tfoot id='7hEDo'></tfoot>

    1. <legend id='7hEDo'><style id='7hEDo'><dir id='7hEDo'><q id='7hEDo'></q></dir></style></legend>

      • <bdo id='7hEDo'></bdo><ul id='7hEDo'></ul>
      1. 快速关闭模态视图控制器时传递数据

        时间:2023-09-12

        1. <small id='NZTDf'></small><noframes id='NZTDf'>

            <bdo id='NZTDf'></bdo><ul id='NZTDf'></ul>
                    <tbody id='NZTDf'></tbody>
                  <tfoot id='NZTDf'></tfoot>

                  <legend id='NZTDf'><style id='NZTDf'><dir id='NZTDf'><q id='NZTDf'></q></dir></style></legend>

                  <i id='NZTDf'><tr id='NZTDf'><dt id='NZTDf'><q id='NZTDf'><span id='NZTDf'><b id='NZTDf'><form id='NZTDf'><ins id='NZTDf'></ins><ul id='NZTDf'></ul><sub id='NZTDf'></sub></form><legend id='NZTDf'></legend><bdo id='NZTDf'><pre id='NZTDf'><center id='NZTDf'></center></pre></bdo></b><th id='NZTDf'></th></span></q></dt></tr></i><div id='NZTDf'><tfoot id='NZTDf'></tfoot><dl id='NZTDf'><fieldset id='NZTDf'></fieldset></dl></div>

                  本文介绍了快速关闭模态视图控制器时传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将数据从 modal ViewController 传递到他的 source ViewController.我想我必须使用delegation,但它不起作用.

                  I'm trying to pass data from the modal ViewController to his source ViewController. I think I have to use delegation but it doesn't work.

                  protocol communicationControllerCamera{
                      func backFromCamera()
                  }
                  
                  class Camera: UIViewController{
                      var delegate: communicationControllerCamera
                  
                      init(){
                          self.delegate.backFromCamera()
                      }
                  }
                  
                  
                  class SceneBuilder: UIViewController, communicationControllerCamera{
                      func backFromCamera(){    // Never called
                          println("YEAHH")
                      }
                  }
                  

                  没有调用 backFromCamera 方法.我做错了什么?

                  The backFromCamera method it's not called. What did I do wrong?

                  推荐答案

                  你没有设置代理,所以当你尝试调用 backFromCamera() 时它是空的.

                  You didn't set a delegate so it was empty when you tried to call backFromCamera().

                  这是一个您可以测试的简单工作示例.请注意委托的可选类型 (?) 的使用.

                  Here's a simple working example you can test out. Notice the use of the optional type (?) for the delegate.

                  // Camera class
                  protocol communicationControllerCamera {
                      func backFromCamera()
                  }
                  
                  class Camera: UIViewController {
                      var delegate: communicationControllerCamera? = nil
                  
                      override func viewDidLoad() {
                          super.viewDidLoad()
                          self.delegate?.backFromCamera()
                      }
                  }
                  
                  
                  
                  // SceneBuilder class
                  class SceneBuilder: UIViewController, communicationControllerCamera {
                  
                     override func viewDidLoad() {
                         super.viewDidLoad()
                     }
                  
                     override func viewDidAppear(animated: Bool) {
                         super.viewDidAppear(animated)
                  
                         var myCamera = Camera()
                         myCamera.delegate = self
                  
                         self.presentModalViewController(myCamera, animated: true)
                     }
                  
                     func backFromCamera() {
                         println("Back from camera")
                     }
                  }
                  

                  您可以在 Apple 的 Swift 文档.

                  这篇关于快速关闭模态视图控制器时传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:NSURLSession 委托与 completionHandler 下一篇:Objective-C 中的匿名委托实现?

                  相关文章

                    <small id='Q77pl'></small><noframes id='Q77pl'>

                    <i id='Q77pl'><tr id='Q77pl'><dt id='Q77pl'><q id='Q77pl'><span id='Q77pl'><b id='Q77pl'><form id='Q77pl'><ins id='Q77pl'></ins><ul id='Q77pl'></ul><sub id='Q77pl'></sub></form><legend id='Q77pl'></legend><bdo id='Q77pl'><pre id='Q77pl'><center id='Q77pl'></center></pre></bdo></b><th id='Q77pl'></th></span></q></dt></tr></i><div id='Q77pl'><tfoot id='Q77pl'></tfoot><dl id='Q77pl'><fieldset id='Q77pl'></fieldset></dl></div>
                    <tfoot id='Q77pl'></tfoot>

                    <legend id='Q77pl'><style id='Q77pl'><dir id='Q77pl'><q id='Q77pl'></q></dir></style></legend>
                      <bdo id='Q77pl'></bdo><ul id='Q77pl'></ul>