【问题标题】:How to pass data from oneviewcontroller to anotherviewcontroller while using swrevealviewcontroller?如何在使用 swrevealviewcontroller 时将数据从 oneviewcontroller 传递到 anotherviewcontroller?
【发布时间】:2016-03-28 11:14:40
【问题描述】:

这是我的代码:

   let swswipe:SWRevealViewController=UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("swswipe") as! SWRevealViewController
        if(indexPath.row==0)
        {

           let swipe=swipeView()
            swipe.collectionClick="one"
            self.presentViewController(swswipe, animated: true, completion: nil)

        }



            front
              |
1st view <->swreveal<->2ndview(swipe)

我正在尝试将值从第 1 个发送到第 2 个,但中间有一个 swrevealview 控制器,所以没有收到该值

但我没有收到任何东西

 print("coming to collection view", self.collectionClick)

【问题讨论】:

  • 你尝试过委托模式吗?
  • 不,我没有尝试委托模式,你能简单解释一下吗@ismail
  • 但我正在使用集合视图,同时单击我需要发送字符串的单元格 ...@ismail

标签: ios objective-c swift uiviewcontroller swrevealviewcontroller


【解决方案1】:

您可以通过以下任何方式执行此操作:

  • 当第二个控制器离开时发送通知并让父级监听它。

  • 创建一个委托协议,让第二个控制器直接引用父方法。

  • (如果需要实现后退按钮操作)使用父级的 viewWillAppear: 并检查 isMovingToParentViewController 属性是否刚刚重新出现。

并应用最适合您的价值传递条件和价值可用性的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    • 2016-02-26
    • 1970-01-01
    • 2014-06-06
    • 2017-11-14
    相关资源
    最近更新 更多