-
Notifications
You must be signed in to change notification settings - Fork 344
INTERNALS: What happens when...
klazuka edited this page Sep 13, 2010
·
2 revisions
- KalGridView will receive the touch events in its touches{Began:,Moved:,Ended:}withEvent: handlers.
- KalGridView marks the tile as selected, which in turn:
- tells KalTileView that it needs to redraw itself.
- tells the delegate that a new date has been selected. The delegate will then tell the dataSource to update the list of data from which it configures UITableViewCells.
- When the touch event finishes, KalGridView will decide to do one of 3 things:
- If the finger was released over a tile that belongs to an adjacent month, it will tell the delegate to show the adjacent month
- If the finger was released over any other type of tile, it will just mark the tile as selected. Once again triggering the side effects of Step #2.
- If the finger was released anywhere else on the screen, it will do nothing.
The first thing to understand is that KalGridView double-buffers the views that represent the grid of tiles (KalMonthView). So there is both a “frontMonthView” and a “backMonthView.” The frontMonthView pointer always points at the view that is being displayed on-screen. For more details about how KalMonthView is double-buffered, see INTERNALS: KalGridView and KalMonthView.
Assume that the user tapped the right arrow image at the top of the calendar.
- KalView tells its delegate, KalViewController, to showFollowingMonth
- KalViewController responds by doing 3 things
- Updates the model state (KalLogic) to reflect the following month.
- Asynchronously tells its dataSource that it will be presenting the date range of visible dates in the following month.
- The dataSource loads its application data for that date range and issues a callback to KalViewController when the data is ready.
- Tells KalView to slideUp, resulting in the following steps:
- KalView will receive the slideUp message and will pass it along to KalGridView.
- KalGridView reconfigures the off-screen backMonthView so that its contents reflect the month that is about to slide on-screen.
- KalGridView then moves backMonthView either above or below frontMonthView (depending on the slide direction).
- Next, KalGridView tells Core Animation that it wants to slide both the frontMonthView and the backMonthView such that backMonthView will be entirely on-screen.
- Just before the animation is triggered, KalGridView swaps the frontMonthView and backMonthView pointers (“flips the buffers”)
- Finally, Core Animation runs the animation.