I am interested in using a page control to switch through entries in my array without changing the view. How can I do this? Is there a tutorial. . .
However, whenever the pages is switched, the background color and some images change. Is there any way to run code once a page is switched?
Thanks
UIPageControlonly represents paging, it does not manage the paging behavior itself. You will need to write your own code to iterate through your array when clicking on theUIPageControl. ThecurrentPageproperty should be set to the index you are working with in your array, thetotalPagesproperty should be set to the array’scountproperty. Finally, you’ll need to setup a target/action pair for theUIControlEventValueChangedevent using-addTarget:action:forControlEvents:The documentation states:
So you can use that event to determine when a page is changed.
Example:
[…]
When you click the page control, it moves forward or backward through the array of strings represented by the
self.itemsproperty.-pageChanged:is where you would update the controls on the view as well.If you want to update the current page in the UIPageControl in another area, simply do: