UIPageControl - 单击按钮重新加载页面 [英] UIPageControl - reload page on click of button

查看:25
本文介绍了UIPageControl - 单击按钮重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UIPageControlUISwipeGestureRecognizer 在页面之间切换.

I am using UIPageControl and UISwipeGestureRecognizer to switch between pages.

这是这个问题的扩展 UIPageControl - 单击按钮更改页面

上述线程中提供的解决方案使我能够更改页面.在我的应用程序中,需要根据按下按钮时传递的参数重新加载下一页.我能够传递参数,当我在下一个视图控制器中执行 NSLog 时我会看到它.但我无法理解为什么页面没有被重新加载.

The solution provided in the above mentioned thread enables me to change the page. In my application, the next page needs to be reloaded based on a parameter that is passed when the button is pressed. I am able to pass the parameter and I see it in when I do NSLog in the next view controller. But I am unable to understand why the page is not being reloaded.

第二个视图包含一个基于我传递的参数加载的图.目前,即使切换到下一页并传递参数,也只能看到初始图.

The second view consists of a plot which loads based on the parameter I pass. Currently, only the initial plot is seen even on switching to the next page and passing the parameter.

该参数在函数中设置第二个视图控制器的全局静态变量.该图是基于第二个视图控制器的 viewDidAppear 方法中的此参数创建的.

The parameter sets a global static variable of the second view controller in a function. The plot is created based on this parameter in the viewDidAppear method of the second view controller.

推荐答案

viewDidAppear 仅在您的视图控制器是容器时调用.您有责任在显示和隐藏子视图控制器视图时调用此(以及相关联的)方法.

viewDidAppear is only called when you call it if your view controller is a container. It's your responsibility to call this (and associated) methods as you show and hide the child view controllers views.

基本上,当您滑动和制作动画时,您应该在之前的两个控制器上调用 will show 和 hide 方法,并在动画完成块中调用两个控制器上的 did show 和 hide 方法.

Basically, when you swipe and animate you should call the will show and hide methods on the 2 controllers just before and the did show and hide methods on both controllers in the animation completion block.

这篇关于UIPageControl - 单击按钮重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆