I need to dynamically create some views in my app and place some buttons on them dynamically again. If the amount (count) of the buttons is more then ten I want to place the buttons on a new view and the transitions between the views must be with UIPageControl. Even though I googled and searched from Apple’s Developer page I couldn’t find a way of solving my problem. Can someone please help?
I need to dynamically create some views in my app and place some buttons
Share
Add your views as side-by-side subviews of an UIScrollView, using the
addSubviewmethod. Then use the UIPageControl with the UIScrollView, as in this example.I made a class that manages a UIScrollView, a UIPageControl, and an array of UIViews. It is a simplified version of what I use in my own code. It does the following:
PageViewManager.h
PageViewManager.m
To use this class, you embed it inside a UIViewController than contains the UIScrollView and the UIPageControl.
Usage:
My sample code assumes that you’re using ARC.