I have my images, but how do I redraw the UIPageControl to use these images?
The UIPageControl does not manage any views for you. It is a very basic control that just displays the dots. It is up to you to implement your 'page' views and navigate between them using 'swipe' gestures or however you want to do it.
See this tutorial for information on how to combine a UIPageControl with two UIViews to navigate between multiple pages.
(To directly address the title of your question - you do not subclass UIPageControl)
See Swip from one view to the next view
Apple also has sample code you can use.
Related
I want to make the horizontal swipeable page like YouTube. Is there an object in XCode for this? How do I have to do it? I did not find a tutorial about it. Sorry for my English.
Like this
There are tons of components already made for this in the internet, you can try looking at the cocoacontrols site.
If you still want to write your own code for this, one way is writing a custom UIView subclass. The YouTube feature looks very simple and as far as I can guess, they can use two separate UIView subclasses: one for the menu and one for the pages, just as a container.
For the menu you can use UIStackViews or a single UIViews with UIButtons for the page's titles and another view for the selection effect that moves with the UIButton's touch event. This view should provide a delegate or any notification system that fits better to you in order to notify the container that needs to load the right UIViewController's view inside the container.
The container can be a UIView that loads the view property from the UIViewController subclass on demand. Make sure to add the loaded view controller as a child of the parent view controller, otherwise you will loose some important features.
I hope it can help you to start.
I would like to know if I could add a UIPageControl to a TableViewController in order to flip sideways between different tables?
What is the right way to go about this?
Is there some sample code to implement this? The code on the Apple website looks complicated for a beginner like me, does not use Storyboards and it only deals with some images.
Thanks for your help!
Instead of using TableViewController, I would just use ViewController implementing UITableView data source and delegate.
Place UITableView and UIPageControl in that and then on change in UIPageControl, change the data source of the tableview and use UITableView.reloadSections with appropriate UITableViewRowAnimation (Right or Left).
You can also add gesture recognizers on the tableview to allow swipe left/right.
I want to be able to dynamically populate UIScrollView. Like how it is done for row views in UITableView. I have a class that takes in some parameters and creates the respective view when it scrolls. Currently I have 8 views.
These 8 views have different background image, image and label according to the page number it is currently in. However the basic skeleton for this view is the same. What i am doing right now is in ViewDidLoad I am creating 8 views and add them as subviews and scroll over.
I don't want to do this. I want to create three views and the rest i want to populate when the user scrolls a page and then a page etc. How do i do this? ANy pointers/tutorial?
First of all you calculate the ContentSize for the scrollview (when you want to use the iPad in landscapemode with 8 pages then the width should be 1024*8 = 8192px and the height 768px).
Then you should implement the UIScrollView Delegate method:
scrollViewDidEndDecelerating:
In this Method you check on which page you currently are with the contentOffset property of the scrollview and start updating your left and right hidden views..
Hope this helps you a bit.
Check the two most recent WWDC videos for two excellent sessions regarding expert use of UIScrollViews. Additionally you can review a brief tutorial here, written by the well known cocoa expert, Matt Gallagher.
I have an application with several (8) different Views in a UIScrollView. They are circling so that you get to the first when you try to get "behind" the last and vice versa.
My problem is how to create a titlebar like in the Stream of the Google+ App. There the titles are circling with the pages and show the current visible page.
How could I realize that? Would it be possible to create a general class to use such a view in many different apps?
I've already tried to solve this problem with some different approaches, but they all didn't work (well). I can display labels above my scrollView and move them, but how far and with which text seems to be difficult for me.
So now I'm looking forward to your answers ;D
Try using two UIScrollView, one for the content and one for the headers. The header UIScrollView would be controlled by your view controller that is also a delegate of the main UIScrollView. Update the header UIScrollView whenever you receive a -scrollViewDidScroll: message from the main UIScrollView.
I think you need to add label in customview and then add customviews in scrollView, you will get events for individual view, so you can rotate that view according to angle and keep label at fix place...
My google-fu is failing here. I'm looking for the name of the UIView (or whatever it is) that handles several pages, with those little glowing dots indicating which page you're on.
UIScrollView is the name of the view with pages
UIPageControl is what you connect to it to add the dots
To expand on coneybeare's brief description, there is no special control that does the pages, it is simply a UIView within a UIScrollView with code to 'lock' the scrolling to certain spots (pages). The UIPageControl is simply a display of which position the scrollview is currently locked to.
A perfect example is Apple's sample code/demo here:
http://developer.apple.com/iphone/library/samplecode/PageControl/index.html