How to use PageControl to view different UITableViews? - iphone

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.

Related

Adding a Button to a UISearchBar with a TableView and Refresh Control

I've been searching for two days for a solution to this problem, and I just can't figure out a cohesive solution. What I'm trying to do is:
Have a UISearchBar with an extra button to the left like in this thread Adding button to left of UISearchBar.
Have a table view that shows the results that the UISearchBar is not part of, so that the search bar stays on screen even if you scroll down in the table view. I was only able to do this by separating the tableview and the search bar, meaning I can't use UITableViewController
Have refresh control on the table view. From this thread UIRefreshControl without UITableViewController it looks like I can't do this in a supported way if I can't use a tableViewController.
I've tried using the UIToolbar solution to adding a button to a UISearchBar, but the gradients don't really blend, so I'd prefer not to use that solution. I also haven't had any luck using any of the code snippets I've found here to add the button in a subclass in a way that can support autolayout for rotation.
Any help is much appreciated!
Perhaps you could make a custom object that just stacks a UISearchBar on top of a UINavigationBar and then use a UIBarButtonItem for the button that you are talking about. If you make this a re-usable custom object, you should be able to implement it app-wide.

UITableview with UIPageControl?

I am in the making of a restaurant "step by step" ordering app, where I want to list the menu (appetizers, main course etc) in a tableview with the ability to organize the menu contents with a UIPagecontrol. Something similar to the eat24 app way of doing it or how the weather forecast app is constructed.
I already have the tableview set up, now I just need to implement this, which I hope you will help me with or guide me in the right direction, for me to accomplish this :). Would I need to setup a tableview for each of the categories or would it be possible to just update one tableview with the needed information, by swiping to the left or use arrows in a toolbar in the picture? What would the best way to add a toolbar like the one picture (white ring), using the storyboard -> resize tableview and drag the image in or to set it up programmatically?
Option 1 - Updating your tableView
You may update your dataSource so it reflects the state of the "new" tableView. Than you call reloadSections:withRowAnimation: by using UITableViewRowAnimationRight or UITableViewRowAnimationLeft, depending of whats fitting at the moment. This will feel like scrolling to a new tableView. For swiping you could use a UISwipeGestureRecognizer.
Option 2 - Using a scrollView with multiple tableViews
If you want it a little bit easier just setup three tableViews and throw them in a UIScrollView with paging enabled.
PageControl
Of course you need to add and setup a UIPageControl, if you want to show those dots.
Regarding the UI:
You can setup everything in your Storyboard. The background, the arrow buttons, the UIPageControl, you can even add the UISwipeGestureRecognizer within the Storyboard.

How can I slide a tableview left/right to acces another view?

How can I slide a tableview left/right to acces another view like the UIPageIndicator?
Can it be (Mainly) done in storyboard?
You might want to take a look at UIPageControl. Check out the following sample code from apple.
http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40007795

Subclassing UIPageControl

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.

UITableView into a UIScrollView?

I'm looking to have two views which are part of a constituent set. Data in each view would be best represented in a UITableView. I'd like to then add a gesture to flicker the view off screen and have another similar view brought in, with a page indicator control. My fear is that UITableView intercepts touches and becomes the responder to any such 'flickering' which the UIView might be waiting for. This will directly impede on the usability of the application.
So my question to you usability/UI experts is, is putting a UITableView inside of UIPageControl a poor design choice?
A UITableView is a subclass of UIScrollView. The PageControl sample provided with the iPhone SDK explains nicely how to use a UIScrollView with UIPageControl. Any method which belongs to UIScrollViewDelegate will be called inside your view controller if the view controller implements UITableViewDelegate.
To achieve what you are trying to do, the best approach would be to use UITableView with UIPageControl as explained in the PageControl sample.
Hope that helps!