Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've implemented something almost identical to this in an application I am developing for a client at the moment.</p> <p>Firstly I would expose a method on your table view controller where you can set the day to display data for:</p> <pre><code>- (void)setDayToDisplayDataFor:(NSDate *)date animated:(BOOL)animated; </code></pre> <p>I've chosen NSDate there and you could for example show data for the next 24 hours starting from that date. Or you can choose another method, whichever works best for you and your data model. An alternative could be an integer representing the number of days backwards to look.</p> <p>I would then develop a custom control (a subclass of UIView) with two left/right arrow buttons on either end and the date in the middle. You can either stick this in the table view's header so it scrolls off the screen or have it above the table view entirely so it remains there when scrolling. Something like this:</p> <p><img src="https://i.stack.imgur.com/3oyx0.png" alt="alt text"></p> <p>When the user taps a button to go forwards/backwards you can slide the current date label out to the left or right and slide the new date in. That gives a visual cue to what has happened.</p> <p>The control should also call out to a delegate to inform it of the change in date. In this case the delegate is just your table view controller. So when the user taps the button you grab the new date from the custom date control and call your <code>setDayToDisplayDataFor:animated:</code> method to display the updated data. You could also animate this table view change if you like.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload