问题
I am using UIPageControl
and UISwipeGestureRecognizer
to switch between pages.
This is an extension to this question UIPageControl - Change page on click of button
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.
Edit: 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.
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/21223143/uipagecontrol-reload-page-on-click-of-button