
我有一个UIPageVIEwController,它以编程方式加载6个子UIVIEw场景.它们托管了“添加”元素功能的各个阶段.目前,PageVIEwController类将每个子视图添加到一个数组中,并在需要时实例化它们:
storyboard?.instantiateVIEwControllerWithIDentifIEr("editVIEwController") 自然委托设置为在每个子场景之间滑动,因此不运行“prepareForSegue”功能.
当页面滑动时,实例化具有不同标识符的新场景.
从我的阅读,我现在正在尝试建立一个委托,该委托采用一个字典的实例,读取/存储该过程的每个阶段(不同的子UIPageVIEw场景)的输入并更新字典.
我使用“vIEwWilldissapear”和“vIEwWillAppear”方法来帮助设置传递数据到委托中.
不幸的是我遇到了问题,由于我缺乏经验,而且对这个具体问题不多,我需要帮助!
主要问题:
我可以在UIPageVIEwController类中设置一个数据委托,“会话”或者可以由子UIVIEws访问吗?
要么
有没有人知道将我的词典从孩子传给孩子的好方法????
您可以从child-> parent->子项传递数据,而不是从child->子项传递数据.首先,当您使用storyboard?.instantiateVIEwControllerWithIDentifIEr(“editVIEwController”)在PageVIEwController中实例化每个子节点时,保存对它的引用.
所以像
var firstVIEwController: EditVIEwController?...firstVIEwController = storyboard?.instantiateVIEwControllerWithIDentifIEr("editVIEwController") as EditVIEwController 接下来,使用self.parentVIEwController在每个子VIEwController中获取对PageVIEwController的引用.
var myPageVIEwController: PageVIEwContrller (or whatever yours is called) ....myPageVIEwController = self.parentVIEwController() as PageVIEwController (or whatever yours is called)
现在,使用这两个引用,您可以在PageVIEwController和子节点中调用函数来来回传递数据.
总结以上是内存溢出为你收集整理的使用Swift在UIPageViewController子视图之间传递数据全部内容,希望文章能够帮你解决使用Swift在UIPageViewController子视图之间传递数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)